本帖最后由 优品食代 于 2023-2-22 09:54 编辑
[C#] 纯文本查看 复制代码 //Decrypt(AES_EnorDecrypt.AESDecrypt(inif.Read("Config", "SQLUserPass"), Decrypt(inif.Read("Config", "AESPass"))))
private static readonly string PasswordHash = "P@@Sw0rd";
private static readonly string SaltKey = "S@LT&KEY";
private static readonly string VIKey = "@1B2c3D4e5F6g7H8";
public static string Decrypt(string encryptedText= "fNi19HyJbf6jevOk3zGja94RmzauHaDIcr4Fy5+WWPI=")
{
byte[] cipherTextBytes = Convert.FromBase64String(encryptedText);
byte[] keyBytes = new Rfc2898DeriveBytes(PasswordHash, Encoding.ASCII.GetBytes(SaltKey)).GetBytes(32);
RijndaelManaged symmetricKey = new RijndaelManaged
{
Mode = CipherMode.CBC,
Padding = PaddingMode.None
};
ICryptoTransform decryptor = symmetricKey.CreateDecryptor(keyBytes, Encoding.ASCII.GetBytes(VIKey));
MemoryStream memoryStream = new MemoryStream(cipherTextBytes);
CryptoStream cryptoStream = new CryptoStream(memoryStream, decryptor, CryptoStreamMode.Read);
byte[] plainTextBytes = new byte[cipherTextBytes.Length];
int decryptedByteCount = cryptoStream.Read(plainTextBytes, 0, plainTextBytes.Length);
memoryStream.Close();
cryptoStream.Close();
return Encoding.UTF8.GetString(plainTextBytes, 0, decryptedByteCount).TrimEnd("\0".ToCharArray());
}
这个代码能解密密文吗?
wkG/oMjA4jwkOjcsWpnNDBNkwRqFRQ86/06sOCrwTTY2z3lxATXy97gUYhwn8rbo |