Labels

Friday, June 8, 2007

Assymetric Encryption

Two asymmetric algorithms

·         DSA [Digital Signature Algorithm]

·         RSA [Rivest, Shamir and Adleman]

 

Asymmetric encryption algorithms often are used to create Digital Signatures.

Typically, one key is made public, and the other key is kept private. If you encrypt a message with your private key, it can be decrypted only with your public key.

If you send another user a message encrypted with your private key, that user can verify that you sent the message by decrypting it with your public key.

 

Way to get Public/Privat pair:

 

Dim objDSA As New DSACryptoServiceProvider()

Private Key= objDSA.ToXmlString (True)

Public Key= objDSA.ToXmlString (False)

 

You can use the SignData method to generate a digital signature for a message.

The VerifyData method performs the opposite operation. You can use this method to verify that a message matches its digital signature.

 

Signing Data:

 

  Dim arrInput As Byte()

  Dim objDSA As DSACryptoServiceProvider

  Dim arrDigitalSignature As Byte()

 

  arrInput = System.Text.Encoding.Default.GetBytes ( txtInput.Text )

  objDSA = New DSACryptoServiceProvider()

  arrDigitalSignature = objDSA.SignData( arrInput )

  txtSignature.Text = System.Text.Encoding.Default.GetString ( arrDigitalSignature )

 

Verifying Data:

 

  Dim arrInput As Byte()

  Dim objDSA As DSACryptoServiceProvider

  Dim strPublicKey As String

  Dim arrDigitalSignature As Byte()

 

  arrInput = System.Text.Encoding.Default.GetBytes ( txtInput.Text )

  arrDigitalSignature = System.Text.Encoding.Default.GetBytes ( txtSignature.Text )

 

  objDSA = New DSACryptoServiceProvider() 

  bool res = objDSA.VerifyData( arrInput, arrDigitalSignature )

 

 

 

Thanks & Regards,

Arun Manglick

SMTS || Microsoft Technology Practice || Bridgestone - Tyre Link || Persistent Systems || 3023-6258

 

DISCLAIMER ========== This e-mail may contain privileged and confidential information which is the property of Persistent Systems Pvt. Ltd. It is intended only for the use of the individual or entity to which it is addressed. If you are not the intended recipient, you are not authorized to read, retain, copy, print, distribute or use this message. If you have received this communication in error, please notify the sender and delete all copies of this message. Persistent Systems Pvt. Ltd. does not accept any liability for virus infected mails.

No comments:

Post a Comment