I have got some application that accepts a License encrypted key. So this application should keep inside string encryptionPassword in order to decrypt that string and get some data.
Which is the best approach to keep string encryptionPassword inside of the application so if the user will try to hack it and it should be extremely difficult to do?
Any clue?
Thank you!!!
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);
}
SecureStringmay fit the bill:Also:
And
Note, however, that aA determined enough user will manage to read such a password – it can take time and effort, but it will be possible