namespace Yw.BIMFace
|
{
|
/// <summary>
|
/// base64格式转换器
|
/// </summary>
|
public static class Base64Extension
|
{
|
/// <summary>
|
/// 使用 UTF8 编码格式,对字符串进行进行 Base64 方式编码(加密)
|
/// </summary>
|
/// <param name="this">扩展对象</param>
|
/// <returns>编码后的字符串</returns>
|
public static string EncryptByBase64(this string @this)
|
{
|
byte[] bytes = Encoding.Default.GetBytes(@this);
|
return Convert.ToBase64String(bytes);
|
}
|
|
/// <summary>
|
/// 使用 UTF8 编码格式,对字符串进行进行 Base64 方式解码(解密)
|
/// </summary>
|
/// <param name="this">扩展对象</param>
|
/// <returns>解码后的字符串</returns>
|
public static string DecryptByBase64(this string @this)
|
{
|
byte[] bytes = Convert.FromBase64String(@this);
|
return Encoding.Default.GetString(bytes);
|
}
|
|
|
|
}
|
}
|