public static string Encrypt(string str)
{
byte[] buffer = HttpContext.Current.Request.ContentEncoding.GetBytes(str);
return HttpUtility.UrlEncode(Convert.ToBase64String(buffer));
}
public static string Decrypt(string cryptstr)
{
byte[] buffer = Convert.FromBase64String(cryptstr);
return HttpContext.Current.Request.ContentEncoding.GetString(buffer);
}
本文提供了两种用于字符串处理的方法:一种是将输入的字符串进行Base64编码后使用URL安全的方式进行编码;另一种是对经过Base64编码的字符串进行解码并还原成原始的字符串内容。这两种方法适用于简单的数据保护场景。
88

被折叠的 条评论
为什么被折叠?



