SimpleEncryptWithPassword() 공개 정적인 메소드

public static SimpleEncryptWithPassword ( byte secretMessage, string password, byte nonSecretPayload = null ) : byte[]
secretMessage byte
password string
nonSecretPayload byte
리턴 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);
            }
        }