我有一些接受许可证加密密钥的应用程序。所以这个应用程序应该保留在里面string encryptionPassword
,以便解密该字符串并获取一些数据。
哪种方法最好保留string encryptionPassword
在应用程序内部,所以如果用户试图破解它并且应该非常难以做到?
有什么线索吗?
谢谢!!!
public static string Encrypt(string textToEncrypt, string encryptionPassword)
{
var algorithm = GetAlgorithm(encryptionPassword);
byte[] encryptedBytes;
using (ICryptoTransform encryptor = algorithm.CreateEncryptor(algorithm.Key, algorithm.IV))
{
byte[] bytesToEncrypt = Encoding.UTF8.GetBytes(textToEncrypt);
encryptedBytes = InMemoryCrypt(bytesToEncrypt, encryptor);
}
return Convert.ToBase64String(encryptedBytes);
}
public static string Decrypt(string encryptedText, string encryptionPassword)
{
var algorithm = GetAlgorithm(encryptionPassword);
byte[] descryptedBytes;
using (ICryptoTransform decryptor = algorithm.CreateDecryptor(algorithm.Key, algorithm.IV))
{
byte[] encryptedBytes = Convert.FromBase64String(encryptedText);
descryptedBytes = InMemoryCrypt(encryptedBytes, decryptor);
}
return Encoding.UTF8.GetString(descryptedBytes);
}