Sign hash with public key

D

Daniel Godoy

Hello all !

I´ve developed a page to do a Asymmetric Cryptography with Digital
Certificate, but something doesn´t work.

I have a URL like that :
"FIELD1=000000000000001&FIELD2=0000&FIELD3=AAAAA&SIGN=5705236f1f462afe65f6704d24c8e1359fead41e42c460d........"

When I receive it, I have to get the Digital Signature of all field and
after compare with the SIGN field. But I can´t cryptography the field using
"SIGNHASH", because my Certificate File (CER) haven´t the Private Key, and
the same time, I can´t use the VERIFYHASH, because I don´t know how convert
the SIGN value to a array of bytes.

The code :
'TextBox1.text = ClearText

'TextBox2.text = SIGN

Dim ClearTextBytes As Byte() = Encoding.UTF8.GetBytes(TextBox1.Text)

Dim AlgHash As HashAlgorithm = HashAlgorithm.Create("SHA1")

Dim hash As Byte() = AlgHash.ComputeHash(ClearTextBytes)

Dim Cert As X509Certificate =
X509Certificate.CreateCertFromFile("C:\CertificateFile.cer")

Dim sign As New RSACryptoServiceProvider

sign.ImportParameters(Cert.PublicKey.ExportParameters(False))

Dim b As Byte

Dim resultHexString As String

MsgBox(sign.VerifyHash(hash, CryptoConfig.MapNameToOID("SHA1"), "????I have
to convert, but I don´t know how ????"))



Thank you !!



Daniel Godoy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,736
Latest member
AdolphBig6

Latest Threads

Top