internal static string Encrypt(ECryptoMethod cryptoMethod, string decrypted) { if (!Enum.IsDefined(typeof(ECryptoMethod), cryptoMethod) || string.IsNullOrEmpty(decrypted)) { ASF.ArchiLogger.LogNullError(nameof(cryptoMethod) + " || " + nameof(decrypted)); return(null); } switch (cryptoMethod) { case ECryptoMethod.PlainText: return(decrypted); case ECryptoMethod.AES: return(EncryptAES(decrypted)); case ECryptoMethod.ProtectedDataForCurrentUser: return(EncryptProtectedDataForCurrentUser(decrypted)); default: ASF.ArchiLogger.LogGenericError(string.Format(Strings.WarningUnknownValuePleaseReport, nameof(cryptoMethod), cryptoMethod)); return(null); } }
internal static string?Decrypt(ECryptoMethod cryptoMethod, string encrypted) { if (!Enum.IsDefined(typeof(ECryptoMethod), cryptoMethod) || string.IsNullOrEmpty(encrypted)) { throw new ArgumentNullException(nameof(cryptoMethod) + " || " + nameof(encrypted)); } return(cryptoMethod switch { ECryptoMethod.PlainText => encrypted, ECryptoMethod.AES => DecryptAES(encrypted), ECryptoMethod.ProtectedDataForCurrentUser => DecryptProtectedDataForCurrentUser(encrypted), _ => throw new ArgumentOutOfRangeException(nameof(cryptoMethod)) });
internal static string Decrypt(ECryptoMethod cryptoMethod, string encrypted) { if (string.IsNullOrEmpty(encrypted)) { Logging.LogNullError(nameof(encrypted)); return null; } switch (cryptoMethod) { case ECryptoMethod.PlainText: return encrypted; case ECryptoMethod.AES: return DecryptAES(encrypted); case ECryptoMethod.ProtectedDataForCurrentUser: return DecryptProtectedDataForCurrentUser(encrypted); default: return null; } }
internal static string Encrypt(ECryptoMethod cryptoMethod, string decrypted) { if (string.IsNullOrEmpty(decrypted)) { ASF.ArchiLogger.LogNullError(nameof(decrypted)); return null; } switch (cryptoMethod) { case ECryptoMethod.PlainText: return decrypted; case ECryptoMethod.AES: return EncryptAES(decrypted); case ECryptoMethod.ProtectedDataForCurrentUser: return EncryptProtectedDataForCurrentUser(decrypted); default: return null; } }
internal static string Decrypt(ECryptoMethod cryptoMethod, string encrypted) { if (string.IsNullOrEmpty(encrypted)) { Logging.LogNullError(nameof(encrypted)); return(null); } switch (cryptoMethod) { case ECryptoMethod.PlainText: return(encrypted); case ECryptoMethod.AES: return(DecryptAES(encrypted)); case ECryptoMethod.ProtectedDataForCurrentUser: return(DecryptProtectedDataForCurrentUser(encrypted)); default: return(null); } }
internal static string Encrypt(ECryptoMethod cryptoMethod, string decrypted) { if (string.IsNullOrEmpty(decrypted)) { ASF.ArchiLogger.LogNullError(nameof(decrypted)); return(null); } switch (cryptoMethod) { case ECryptoMethod.PlainText: return(decrypted); case ECryptoMethod.AES: return(EncryptAES(decrypted)); case ECryptoMethod.ProtectedDataForCurrentUser: return(EncryptProtectedDataForCurrentUser(decrypted)); default: return(null); } }