Web Crypto: sign/verify
This page shows how to use the sign()
and
verify()
functions of the
Web Crypto API. It contains examples for the following signing algorithms:
- "RSASSA-PKCS1-v1_5"
- "RSA-PSS"
- "ECDSA"
- "HMAC"
-
"Ed25519"
-
Caution: For information about
Ed25519 support, see
SubtleCrypto: Browser compatibility
and
Secure Curves in the Web Cryptography API. Chrome requires the
enable-experimental-web-platform-features
preference to be set via command-line switch or viachrome://flags/#enable-experimental-web-platform-features
.
-
Caution: For information about
Ed25519 support, see
SubtleCrypto: Browser compatibility
and
Secure Curves in the Web Cryptography API. Chrome requires the
Each example has four components:
- A text box containing a message to sign.
- A representation of the signature.
- A "Sign" button: this signs the text box contents, displays part of the signature, and stores the complete signature.
- A "Verify" button: this verifies the text box contents against the stored signature, and styles the displayed signature according to the result.
Try it:
- Press "Sign". The signature should appear.
- Press "Verify". The signature should be styled as valid.
- Edit the text box contents.
- Press "Verify". The signature should be styled as invalid.
RSASSA-PKCS1-v1_5
Signature:
RSA-PSS
Signature:
ECDSA
Signature:
HMAC
Signature:
Ed25519
Signature: