Module Module1
Sub Main()
'The hash value to sign.
Dim HashValue As Byte() = {59, 4, 248, 102, 77, 97, 142, 201, 210, 12, 224, 93, 25, 41, 100, 197, 213, 134, 130, 135}
'The value to hold the signed value.
Dim SignedHashValue() As Byte
'Generate a public/private key pair.
Dim RSA As New RSACryptoServiceProvider()
'Create an RSAPKCS1SignatureFormatter object and pass it
'the RSACryptoServiceProvider to transfer the private key.
Dim RSAFormatter As New RSAPKCS1SignatureFormatter(RSA)
'Set the hash algorithm to SHA1.
RSAFormatter.SetHashAlgorithm("SHA1")
'Create a signature for HashValue and assign it to
'SignedHashValue.
SignedHashValue = RSAFormatter.CreateSignature(HashValue)
End Sub
End Module
using System;
using System.Security.Cryptography;
[C#]
class Class1
{
static void Main()
{
//The hash value to sign.
byte[] HashValue = {59,4,248,102,77,97,142,201,210,12,224,93,25,41,100,197,213,134,130,135};
//The value to hold the signed value.
byte[] SignedHashValue;
//Generate a public/private key pair.
RSACryptoServiceProvider RSA = new RSACryptoServiceProvider();
//Create an RSAPKCS1SignatureFormatter object and pass it the
//RSACryptoServiceProvider to transfer the private key.
RSAPKCS1SignatureFormatter RSAFormatter = new RSAPKCS1SignatureFormatter(RSA);
//Set the hash algorithm to SHA1.
RSAFormatter.SetHashAlgorithm("SHA1");
//Create a signature for HashValue and assign it to
//SignedHashValue.
SignedHashValue = RSAFormatter.CreateSignature(HashValue);
}
}