星期三, 十月 11, 2006

[C#]将普通字符串转换为Base64编码字符串

// 将字符串转换为Base64编码
Byte[] buf = System.Text.ASCIIEncoding.UTF8.GetBytes(sourceString);
String resultString = Convert.ToBase64String(buf, 0, buf.Length);


// 从Base64编码转换回一般字符串
Byte[] bufout = Convert.FromBase64String(EncryptedString);
String resultString = System.Text.ASCIIEncoding.UTF8.GetString(bufout);

没有评论: