Encrypted Strings

D

David Kyle

Hello,

I'm building a web application where I need to have some post data
encrypted. An example would be something like this:
<input type=hidden value='<%# GetEncriptedData() %>'>

GetEncryptedData() returns a string value that I can post.

I will be using a symmetric algorithm; most likely the Rijndael algorithm.
I don't have any problem encrypting my data but the issue lies in the fact
that I am left with the encrypted data in a byte array (byte[]). I believe
I need to somehow convert this to a string format and then run it through
the Server.URLEncode() method so that the string is then postable.

I will also need to convert it back to bytes. Obviously using
Server.URLDecode() and then some other method.

Any help would be greatly appreciated!

David Kyle
www.chloemag.com
 
B

Bill

You will need to use the ToBase64String() method. This is because the
encrypted data will contain binary data which can not be put in to a string
object.

BYTEARRAY = EncryptData()
STRING = System.Convert.ToBase64String(BYTEARRAY)

<input type=hidden name=data value='<%# Server.UrlEncode(STRING ) %>'>

Then before decoding use

STRING = Server.URLDecode(Request("data"))
BYTEARRAY = System.Convert.FromBase64String(STRING )
DecryptData(BYTEARRAY)

Bill
 
D

David Kyle

My God! Your a god sent Bill! Thanks so much for the help. It works
wonderfully!

Cheers!

David Kyle
www.chloemag.com

Bill said:
You will need to use the ToBase64String() method. This is because the
encrypted data will contain binary data which can not be put in to a
string object.

BYTEARRAY = EncryptData()
STRING = System.Convert.ToBase64String(BYTEARRAY)

<input type=hidden name=data value='<%# Server.UrlEncode(STRING ) %>'>

Then before decoding use

STRING = Server.URLDecode(Request("data"))
BYTEARRAY = System.Convert.FromBase64String(STRING )
DecryptData(BYTEARRAY)

Bill

David Kyle said:
Hello,

I'm building a web application where I need to have some post data
encrypted. An example would be something like this:
<input type=hidden value='<%# GetEncriptedData() %>'>

GetEncryptedData() returns a string value that I can post.

I will be using a symmetric algorithm; most likely the Rijndael
algorithm. I don't have any problem encrypting my data but the issue lies
in the fact that I am left with the encrypted data in a byte array
(byte[]). I believe I need to somehow convert this to a string format
and then run it through the Server.URLEncode() method so that the string
is then postable.

I will also need to convert it back to bytes. Obviously using
Server.URLDecode() and then some other method.

Any help would be greatly appreciated!

David Kyle
www.chloemag.com
 

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,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top