Hi
This question follows on from 21556745.
I used the example question 21556745 in a desktop form fine and it works. However if I use the DLL in a web application I get problems with
A first chance exception of type 'System.FormatException' occurred
The aspx page loads an encrypted textfile then tries to decrypt it to a string.
Here's my code to load a file and then try to decrypt it to a string...
If FileUpload1.HasFile Then
Dim intFileLength As Integer, bytData() As Byte
Dim objStream As System.IO.Stream
intFileLength = FileUpload1.PostedFile.ContentLength
ReDim bytData(intFileLength)
objStream = FileUpload1.PostedFile.InputStream
objStream.Read(bytData, 0, intFileLength)
Dim fileContents As String = Encoding.ASCII.GetString(bytData)
'this displays the file contents
Me.TextBox_ReadFromFile.Text = fileContents
'attempt to decrypt the string
Dim decrypted As String = Crypto.Decrypt(fileContents, "theKeyHEre")
'ERROR Happens here...
Me.DecryptedFromFile.Text = fileContents
End If
so....text loads fine but decrypt doesn't work.
However, if I have the following code in design mode
fileContents = "a long string with exactly the same as is in the file being uploaded"
decrypted = Crypto.Decrypt(fileContents, "theKeyHEre")
there is no error and the text decrypts fine.
Why would this be happening? Text loaded from a file doesn't decrypted, the same text hard coded into class does - what's the solution? This is a strange one..
Thanks
Me.TextBox_ReadFromFile.Te