VerifyFileSignature[{"file",sig},key]
verifies the digital signature sig for file using the specified public key.
VerifyFileSignature[{"file",range,sig},key]
verifies the digital signature sig for the specified range of bytes in the file.
VerifyFileSignature[{{"file1",range1,sig1},{"file2",range2,sig2},…},key]
verifies the digital signatures sigi for each of rangei of bytes in the filei, all using the specified public key.
VerifyFileSignature[key]
represents an operator form of VerifyFileSignature that can be applied to files.
VerifyFileSignature
VerifyFileSignature[{"file",sig},key]
verifies the digital signature sig for file using the specified public key.
VerifyFileSignature[{"file",range,sig},key]
verifies the digital signature sig for the specified range of bytes in the file.
VerifyFileSignature[{{"file1",range1,sig1},{"file2",range2,sig2},…},key]
verifies the digital signatures sigi for each of rangei of bytes in the filei, all using the specified public key.
VerifyFileSignature[key]
represents an operator form of VerifyFileSignature that can be applied to files.
Details
- The signature in VerifyFileSignature must be a DigitalSignature object generated by GenerateFileSignature.
- The key is a PublicKey object. Possible types of keys are "EllipticCurve" and "RSA".
- VerifyFileSignature returns True or False for each provided signature, indicating whether or not the signatures are valid.
- VerifyFileSignature supports the following range specifications:
-
n first n bytes -n last n bytes {m,n} bytes m through n 0 no bytes All all bytes - Range specification All is equivalent to {1,-1}.
- Signature verification for File["file"] and CloudObject[…] is also supported.
Examples
open all close allBasic Examples (2)
Generate an RSA–based key pair:
keys = GenerateAsymmetricKeyPair["RSA"]Generate a digital signature of the file using your private key:
file = FindFile["ExampleData/document.nb"];signature = GenerateFileSignature[file, keys["PrivateKey"]]Verify a digital signature using your public key:
VerifyFileSignature[{file, signature}, keys["PublicKey"]]Sign a file using a hashing function of your choice:
keys = GenerateAsymmetricKeyPair["EllipticCurve"];file = FindFile["ExampleData/ocelot.jpg"];signature = GenerateFileSignature[file, keys["PrivateKey"], Method -> <|"HashingMethod" -> "Keccak512"|>]Verification will automatically consider the hashing function used for signing:
VerifyFileSignature[{file, signature}, keys["PublicKey"]]Scope (5)
File Types (2)
Digitally sign and verify a signed CloudObject:
object = CloudPut[123, "test"];keys = GenerateAsymmetricKeyPair["RSA"];signature = GenerateFileSignature[object, keys["PrivateKey"]]VerifyFileSignature[{object, signature}, keys["PublicKey"]]Create and verify a signature of the file specified by a File object:
file = File[FindFile["ExampleData/spikey2.png"]];keys = GenerateAsymmetricKeyPair["EllipticCurve"];signature = GenerateFileSignature[file, keys["PrivateKey"]]VerifyFileSignature[{file, signature}, keys["PublicKey"]]Byte Ranges (1)
If the signature was created for a range of bytes in the file, VerifyFileSignature will need the same range specified:
keys = GenerateAsymmetricKeyPair["EllipticCurve"];file = FindFile["ExampleData/spikey2.png"];Compute a signature for the first 100 bytes of a file:
signature = GenerateFileSignature[{file, 100}, keys["PrivateKey"]]Verify the signature for the same range of bytes:
VerifyFileSignature[{file, 100, signature}, keys["PublicKey"]]The signature will not be valid for a different range of bytes or the whole file:
VerifyFileSignature[{file, 300, signature}, keys["PublicKey"]]VerifyFileSignature[{file, signature}, keys["PublicKey"]]Operator Form (1)
Generate an elliptic curve–based key pair:
keys = GenerateAsymmetricKeyPair["EllipticCurve"];Apply the operator form of GenerateDigitalSignature to a file:
file = FindFile["ExampleData/glasses.png"];signature = GenerateFileSignature[keys["PrivateKey"]][file]Verify a digital signature using your public key:
VerifyFileSignature[keys["PublicKey"]][{file, signature}]Multiple Files (1)
Sign several files with the same set of keys:
keys = GenerateAsymmetricKeyPair["EllipticCurve"];files = {FindFile["ExampleData/ocelot.jpg"], FindFile["ExampleData/glasses.png"]};signatures = GenerateFileSignature[keys["PrivateKey"]][files]VerifyFileSignature[keys["PublicKey"]][Transpose[{files, signatures}]]Properties & Relations (1)
Uploading a file to the Wolfram Cloud keeps the contents of the file intact. When verifying the digital signatures of the original file and the cloud copy, they are both valid:
keys = GenerateAsymmetricKeyPair["EllipticCurve"];file = FindFile["ExampleData/document.nb"];cloud = CopyFile[file, CloudObject["document-copy.nb"]];Create the signature for both the local and cloud copies of the file:
{sig1, sig2} = GenerateFileSignature[keys["PrivateKey"]][{file, cloud}]All possible combinations of files and signatures are valid:
VerifyFileSignature[keys["PublicKey"]][
Tuples[{{file, cloud}, {sig1, sig2}}]]Related Guides
History
Text
Wolfram Research (2020), VerifyFileSignature, Wolfram Language function, https://reference.wolfram.com/language/ref/VerifyFileSignature.html.
CMS
Wolfram Language. 2020. "VerifyFileSignature." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/VerifyFileSignature.html.
APA
Wolfram Language. (2020). VerifyFileSignature. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/VerifyFileSignature.html
BibTeX
@misc{reference.wolfram_2026_verifyfilesignature, author="Wolfram Research", title="{VerifyFileSignature}", year="2020", howpublished="\url{https://reference.wolfram.com/language/ref/VerifyFileSignature.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_verifyfilesignature, organization={Wolfram Research}, title={VerifyFileSignature}, year={2020}, url={https://reference.wolfram.com/language/ref/VerifyFileSignature.html}, note=[Accessed: 13-June-2026]}