RSAPKCS1SignatureFormatter/ RSAPKCS1SignatureDeformatter
Imports System
Imports System.Security.Cryptography
Class MainClass
Shared Sub Main()
Dim RSA As New RSACryptoServiceProvider()
Dim Hash As Byte() = {9, 4, 8, 102, 77, 97, 142, 201, 210, 12, 224, 93, 25, 41, 100, 197, 213, 134, 130, 135}
Dim RSAFormatter As New RSAPKCS1SignatureFormatter(RSA)
RSAFormatter.SetHashAlgorithm("SHA1")
Dim SignedHash As Byte() = RSAFormatter.CreateSignature(Hash)
Dim RSADeformatter As New RSAPKCS1SignatureDeformatter(RSA)
RSADeformatter.SetHashAlgorithm("SHA1")
If RSADeformatter.VerifySignature(Hash, SignedHash) Then
Console.WriteLine("The signature was verified.")
Else
Console.WriteLine("The signature was not verified.")
End If
End Sub
End Class
Related examples in the same category