/// <summary> /// Décrypter une chaine de caractère /// </summary> /// <param name="input">text value</param> /// <param name="cryptoInformation">informations de cryptage</param> /// <returns></returns> public static string Decrypt(this string input, SECURITY.CRYPTO.ICryptoOption cryptoInformation) { if (string.IsNullOrEmpty(input)) { return(string.Empty); } byte[] bytesToBeDecrypted = Convert.FromBase64String(input); byte[] bytesDecrypted = SECURITY.CRYPTO.CryptoTools.Decrypt(bytesToBeDecrypted, cryptoInformation); string result = Encoding.UTF8.GetString(bytesDecrypted); return(result); }
/// <summary> /// Encrypter une chaine de caratère /// </summary> /// <param name="input">text value</param> /// <param name="cryptoInformation">informations de cryptage</param> /// <returns></returns> public static string Encrypt(this string input, SECURITY.CRYPTO.ICryptoOption cryptoInformation) { //https://webman.developpez.com/articles/dotnet/aes-rijndael/ //https://stackoverflow.com/questions/32972126/creating-decrypt-passwords-with-salt-iv if (string.IsNullOrEmpty(input)) { return(string.Empty); } byte[] bytesToBeEncrypted = Encoding.UTF8.GetBytes(input); byte[] bytesEncrypted = SECURITY.CRYPTO.CryptoTools.Encrypt(bytesToBeEncrypted, cryptoInformation); string result = Convert.ToBase64String(bytesEncrypted); return(result); }