Click here to Skip to main content
15,887,341 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
C#
byte[]cipherbytes = Encoding.ASCII.GetString(label6.Text);
System.IO.MemoryStream ms = new System.IO.MemoryStream(cipherbytes);


What I have tried:

I want to store the label6.text value in byte[]cipherbytes..how to do that please help me
Posted
Updated 24-Mar-16 7:13am
v3

1 solution

C#
byte[]cipherbytes = Encoding.ASCII.GetBytes(label6.Text);
 
Share this answer
 
Comments
Member 10549697 24-Mar-16 13:13pm    
now it says padding cannot be removed...here is my entire code
Member 10549697 24-Mar-16 13:13pm    
byte[] cipherbytes = Encoding.ASCII.GetBytes(label6.Text);
System.IO.MemoryStream ms = new System.IO.MemoryStream(cipherbytes);
CryptoStream cs = new CryptoStream(ms, desObj.CreateDecryptor(), CryptoStreamMode.Read);
cs.Read(cipherbytes, 0, cipherbytes.Length);
plainbytes2 = ms.ToArray();
cs.Close();
ms.Close();
string garbage = Encoding.ASCII.GetString(plainbytes2);
label2.Text = garbage.Substring(0, plainbytes.Length);
}
F-ES Sitecore 24-Mar-16 17:20pm    
There isn't enough code there to know what you're doing, it looks like you're pretty much copying this code so have a read of the thread

http://stackoverflow.com/questions/25013380/how-to-remove-padding-in-decryption-in-c-sharp
Member 10549697 24-Mar-16 21:46pm    
yes sir i'm doing the same thing but i am writing the code in 2 forms...i.e one form for encryption and one for decryption..and it's not working..i am posting my code below..please help me
Afzaal Ahmad Zeeshan 24-Mar-16 14:36pm    
5ed.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900