cryptostream
-
Hi, I want to make an encryptation to a string but the result to be places in a textbox. I tried the cryptostream class but it work only with stream. thanks
-
Hi, I want to make an encryptation to a string but the result to be places in a textbox. I tried the cryptostream class but it work only with stream. thanks
You should be able to write out the stream to a byte array and then convert the byte array to a string. Here are some methods I have used, sorry they are in C# They should be easy to re-write in vb.net
public static String MemoryStreamToString(MemoryStream p_ms)
{
return MemoryStreamToString(p_ms, Encoding.Default);
}
public static String MemoryStreamToString(MemoryStream p_ms, Encoding p_encoding)
{
return ByteArrayToString(p_ms.GetBuffer(), p_encoding);
}public static MemoryStream StringToMemoryStream(String p_string)
{
return StringToMemoryStream(p_string, Encoding.Default);
}
public static MemoryStream StringToMemoryStream(String p_string, Encoding p_encoding)
{
return new MemoryStream(StringToByteArray(p_string, p_encoding));
}public static Byte[] StringToByteArray(string p_str)
{
return StringToByteArray(p_str, Encoding.Default);
}
public static Byte[] StringToByteArray(string p_str, Encoding p_encoding)
{
return p_encoding.GetBytes(p_str);
}public static string ByteArrayToString(byte[] p_byteArray)
{
return ByteArrayToString(p_byteArray, Encoding.Default);
}
public static string ByteArrayToString(byte[] p_byteArray, Encoding p_encoding)
{
int numberOfBytes = p_byteArray.Length;
return p_encoding.GetString(p_byteArray, 0, numberOfBytes);
}Hope that helps. Ben