SimpleEncryptWithPassword() public static method

public static SimpleEncryptWithPassword ( byte secretMessage, string password, byte nonSecretPayload = null ) : byte[]
secretMessage byte
password string
nonSecretPayload byte
return byte[]
 public static string SimpleEncryptWithPassword(string secretMessage, string password, byte[] nonSecretPayload = null)
 {
     if (string.IsNullOrEmpty(secretMessage))
     {
         throw new ArgumentException("Secret Message Required!", nameof(secretMessage));
     }
     return(Convert.ToBase64String(AESThenHMAC.SimpleEncryptWithPassword(Encoding.UTF8.GetBytes(secretMessage), password, nonSecretPayload)));
 }
示例#2
0
 public static byte[] EncryptDataWithPassword(byte[] plainData, string password)
 {
     try
     {
         return(AESThenHMAC.SimpleEncryptWithPassword(plainData, password, SEBProtectionController.RNCRYPTOR_HEADER));
     }
     catch (CryptographicException ex)
     {
         return((byte[])null);
     }
     catch (Exception ex)
     {
         return((byte[])null);
     }
 }
示例#3
0
        /// ----------------------------------------------------------------------------------------
        /// <summary>
        /// Encrypt with password, key, salt using AES (Open SSL Encrypt).
        /// </summary>
        /// ----------------------------------------------------------------------------------------
        public static byte[] EncryptDataWithPassword(byte[] plainData, string password)
        {
            try
            {
                // encrypt bytes
                byte[] encryptedData = AESThenHMAC.SimpleEncryptWithPassword(plainData, password, RNCRYPTOR_HEADER);

                return(encryptedData);
            }
            catch (CryptographicException cex)
            {
                //return cex.Message;
                return(null);
            }
            catch (Exception ex)
            {
                //return ex.Message;
                return(null);
            }
        }