Back to product page
Sign method
Signs the contents of the Blob.
Type
NoneSyntax
- Basic
Remarks
The Sign method will use one of these algorithms (RSA or DSA) with MD5 digest, and apply it to the input Blob. As a result, a fixed length signature will be created. To create a signature, you must have a private key set in the SecretKey property. If you wish to use SHA1 digest instead of MD5, you should use RSA+SHA1 or DSA+SHA1 constants.You can pass such signatures, together with the public part of your key, to other parties, which can then use the Verify method to determine if the signature matches the key - proving that you are really the person that signed the data - in other words, the data originates from you.
Code sample
- Basic
To create your private and public keys (the public key is derived from the private key), you can use the wodKeys object (provided in the setup package). Typically, you can create it like this:
Dim Key As New Keys
Key.Generate DSAkey
Key.Save DSAkey, "C:\keys\dsa.pem"
Once such a key is generated and saved, you can use it to sign data:
Dim crypt As New wodCryptCom
Dim i_blob As New MemBlob
Dim o_blob As New MemBlob
Dim Key As New Keys
Key.Load "c:\keys\dsa.pem"
i_blob.Text = "data to be signed"
crypt.Type = DSA
crypt.SecretKey = Key.PrivateKey(DSAkey)
crypt.Sign i_blob, o_blob
Debug.Print o_blob.ToBase64
result:
MC4CFQDoYDKp8Owxfp5iAmI5MIumvLY3BgIVAK5bqQgQ9W3OGA7DgCtML40uuKBL
You should then give the value of your Key.PublicKey property and the above signature to the other party so they can prove that the signature belongs to you (only by having your public key).
Dim Key As New Keys
Key.Generate DSAkey
Key.Save DSAkey, "C:\keys\dsa.pem"
Once such a key is generated and saved, you can use it to sign data:
Dim crypt As New wodCryptCom
Dim i_blob As New MemBlob
Dim o_blob As New MemBlob
Dim Key As New Keys
Key.Load "c:\keys\dsa.pem"
i_blob.Text = "data to be signed"
crypt.Type = DSA
crypt.SecretKey = Key.PrivateKey(DSAkey)
crypt.Sign i_blob, o_blob
Debug.Print o_blob.ToBase64
result:
MC4CFQDoYDKp8Owxfp5iAmI5MIumvLY3BgIVAK5bqQgQ9W3OGA7DgCtML40uuKBL
You should then give the value of your Key.PublicKey property and the above signature to the other party so they can prove that the signature belongs to you (only by having your public key).