按 Ctrl+C 复制代码
public class DesHelper
{
private static String _ConstValue = "12345678";
public static String Decipher(String Str, bool IncludeLocalInfo)
{
if (null == Str || 0 == Str.Length) return "";
try
{
SymmetricAlgorithm sa = new DESCryptoServiceProvider();
String _Key = _ConstValue;
sa.Key = Encoding.UTF8.GetBytes(_Key);
sa.IV = Encoding.UTF8.GetBytes(_ConstValue);
sa.Mode = System.Security.Cryptography.CipherMode.ECB;
sa.Padding = PaddingMode.PKCS7;
ICryptoTransform ct = sa.CreateDecryptor();
byte[] byt = Convert.FromBase64String(Str);
MemoryStream ms = new MemoryStream();
CryptoStream cs = new CryptoStream(ms, ct, CryptoStreamMode.Write);
cs.Write(byt, 0, byt.Length);
cs.FlushFinalBlock();
cs.Close();
return Encoding.UTF8.GetString(ms.ToArray());
}
catch(Exception e) {
}
return "";
}
}
按 Ctrl+C 复制代码