RSA Encryption - Bad Length Error
From: Wayne P. (infinite@nospam-totalink.net)
Date: 03/23/03
- Next message: Blair: "aspnet_wp.exe could not be launched...HELP!"
- Previous message: andrewcw: "resolving second logon name"
- Next in thread: Joost Schipperheijn: "Re: RSA Encryption - Bad Length Error"
- Reply: Joost Schipperheijn: "Re: RSA Encryption - Bad Length Error"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
From: "Wayne P." <infinite@nospam-totalink.net> Date: Sun, 23 Mar 2003 10:56:30 -0500
I am playing around with RSA to learn about it with the end goal of creating
a Licensing solution for an application. This is code from my sample 'Play'
applicaiton.
Everything works great until the line:
Dim CryptData() As Byte = rsa.Encrypt(toCrypt, True)
I get a Bad Length Error - Any insight would be helpful. Thanks - see my
code below....
Private Sub btnEncryptData_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnEncryptData.Click
Dim rsa As RSACryptoServiceProvider = New RSACryptoServiceProvider(1024)
rsa.FromXmlString(strPrivateKey)
Dim fIn As New FileStream("emp.xml", FileMode.Open)
Dim fOut As New FileStream("emp_crypt.txt", FileMode.Create)
Dim dataIn As New StreamReader(fIn)
Dim dataOut As New StreamWriter(fOut)
Dim myData As String
myData = dataIn.ReadToEnd
dataIn.Close()
Dim toCrypt() As Byte = System.Text.Encoding.Unicode.GetBytes(myData)
Dim CryptData() As Byte = rsa.Encrypt(toCrypt, True)
dataOut.Write(CryptData)
dataOut.Close()
fIn.Close()
fOut.Close()
End Sub
Thanks for your help!
Wayne P.
- Next message: Blair: "aspnet_wp.exe could not be launched...HELP!"
- Previous message: andrewcw: "resolving second logon name"
- Next in thread: Joost Schipperheijn: "Re: RSA Encryption - Bad Length Error"
- Reply: Joost Schipperheijn: "Re: RSA Encryption - Bad Length Error"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|
|