HomeGuides › Digital signatures

How to sign a file or message digitally

A signature answers a question encryption does not: who produced this, and has it changed since?

Encryption and signing solve opposite problems and people routinely confuse them. Encryption makes something unreadable to everyone without the key. Signing leaves it perfectly readable and attaches proof of who produced it — and proof that not one byte has changed since.

Step-by-step: signing

  1. Have a key pair. If you do not, generate one first.
  2. Load your private key. It stays in the page and is never sent.
  3. Choose what to sign — text, or a file.
  4. Sign, and publish the signature alongside the thing it signs.

Step-by-step: verifying

  1. Load the signer's public key.
  2. Add the file or text, and the signature.
  3. Read the verdict. Valid means this exact content was signed by the holder of the private key matching that public key.

What a valid signature does and does not tell you

It tells you the content is unchanged and that whoever holds that private key signed it. That is a strong statement, and it is narrower than people assume.

It does not tell you the key belongs to the person you think. Anyone can generate a key pair and put any name on it. A signature is only as meaningful as your reason for believing the public key is theirs — which comes from somewhere else entirely: you were handed it in person, it is published somewhere you already trust, or a certificate authority vouches for it.

Verifying a signature against a public key you got from the same page as the file proves that the page is internally consistent. It proves nothing about who wrote it.

Which algorithm

Frequently asked questions

Does my private key leave the page?

No. It is used in your browser and never transmitted. Nothing on the page is permitted to send a key anywhere.

What is the difference between signing and encrypting?

Signing proves origin and integrity while leaving the content readable. Encrypting hides the content. They are independent — you can do either, both, or neither.

The signature is valid but I still do not trust the file. Am I missing something?

No, you are reasoning correctly. Validity only ties the content to a key. Whether that key belongs to someone you trust is a separate question the mathematics cannot answer.

Open digital signatures →