|
-
Jun 17th, 2010, 10:49 AM
#1
Thread Starter
Junior Member
[RESOLVED] Output decrypted text with CryptoStream
Hi. Im using a sample code from msnd website - CryptoStream Class (http://msdn.microsoft.com/en-us/libr...ptostream.aspx)
Using this code, i was expecting that
Final would show me the decrypted text from the file
Code:
Dim Final As String = DecryptTextFromFile(FileName, RijndaelAlg.Key, RijndaelAlg.IV)
However, when i try to do something to display Final, like MsgBox(Final) or Label1.text = Final , it outputs nothing.
Where am i wrong?
-
Jun 18th, 2010, 04:36 AM
#2
Frenzied Member
Re: Output decrypted text with CryptoStream
Hi,
are you sure Compact Framework supports this?
Take a look at http://msdn.microsoft.com/en-us/library/aa446559.aspx - there are notes on cryptographt part way down the page - I think you just have to use the crypto API
-
Jun 18th, 2010, 05:45 AM
#3
Thread Starter
Junior Member
Re: Output decrypted text with CryptoStream
 Originally Posted by petevick
Yes, it does. I found out that If i do the sample code from msdn like
Code:
' Create a string to encrypt.
Dim sData As String = "Here is some data to encrypt."
Dim FileName As String = "CText.txt"
' Encrypt text to a file using the file name, key, and IV.
EncryptTextToFile(sData, FileName, RijndaelAlg.Key, RijndaelAlg.IV)
' Decrypt the text from a file using the file name, key, and IV.
Dim Final As String = DecryptTextFromFile(FileName, RijndaelAlg.Key, RijndaelAlg.IV)
It works on my mobile.
However, if i already have the CText.txt and just try to decrypt it like
Code:
' Create a string to encrypt.
Dim sData As String = "Here is some data to encrypt."
Dim FileName As String = "CText.txt"
' Encrypt text to a file using the file name, key, and IV.
' EncryptTextToFile(sData, FileName, RijndaelAlg.Key, RijndaelAlg.IV)
' Decrypt the text from a file using the file name, key, and IV.
Dim Final As String = DecryptTextFromFile(FileName, RijndaelAlg.Key, RijndaelAlg.IV)
It does not work.
I dont understand why drecrypt only does not work (even if it was previously encrypted with the same program, and only works if its first encrypted.
Maybe because it generates a Key and IV each time the program runs? Maybe i need to store the Key and IV in the registry or in somewhere else so i can get it later?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|