Ejemplo n.º 1
0
 private static char[] EncryptPassword(byte[] plaintext, byte[] publicKey)
 {
     try
     {
         byte[] ciphertext = SealedPublicKeyBox.Create(plaintext, publicKey);
         return(Convert.ToBase64String(ciphertext).ToCharArray());
     }
     catch (Exception ex) when(ExceptionFilters.PasswordSharingExceptions(ex))
     {
         Logging.LogException(ex.ToString(), Logging.Severity.Low);
         GetErrorMessage(ex, "Encryption");
         return(Array.Empty <char>());
     }
 }
Ejemplo n.º 2
0
 private static char[] DecryptPassword(byte[] ciphertext, byte[] privateKey)
 {
     try
     {
         using (var keyPair = PublicKeyBox.GenerateKeyPair(privateKey))
         {
             byte[] plaintext = SealedPublicKeyBox.Open(ciphertext, keyPair);
             return(Encoding.UTF8.GetChars(plaintext));
         }
     }
     catch (Exception ex) when(ExceptionFilters.PasswordSharingExceptions(ex))
     {
         Logging.LogException(ex.ToString(), Logging.Severity.Low);
         GetErrorMessage(ex, "Decryption");
         return(Array.Empty <char>());
     }
 }