private static GetDataEncryptionKey ( ) : string | ||
Résultat | string |
/// <summary> /// Tries to encrypt the string. Use this in situations where you might just want to skip encryption if it doesn't work. /// You should use EncryptString in most cases. /// </summary> /// <param name="plainText">The plain text.</param> /// <param name="cypherText">The cypher text.</param> /// <returns></returns> public static bool TryEncryptString(string plainText, out string cypherText) { cypherText = null; string encryptionKey = Encryption.GetDataEncryptionKey(); // non-web apps might not have the DataEncryptionKey, so check that first since it could happen quite a bit if (string.IsNullOrWhiteSpace(encryptionKey)) { return(false); } else { try { cypherText = EncryptString(plainText, encryptionKey); return(true); } catch { // intentionally ignore exception since we are a try method return(false); } } }
/// <summary> /// Encrypt the given string using AES. The string can be decrypted using /// DecryptString(). The sharedSecret parameters must match. /// </summary> /// <param name="plainText">The text to encrypt.</param> public static string EncryptString(string plainText) { string dataEncryptionKey = Encryption.GetDataEncryptionKey(); return(EncryptString(plainText, dataEncryptionKey)); }