public void AsymmetricEncryptTest() { var keys = AsymmetricEncryptor.MakeKeys(RSAKeySize.Key4096); string data = "The quick brown fox jumped over the lazy dog"; string encrypted = AsymmetricEncryptor.Encrypt(data, keys.pk); string decrypted = AsymmetricEncryptor.Decrypt(encrypted, keys.sk); Assert.IsTrue(data == decrypted); }
public void Encrypt_And_Decrypt() { var hmacKey = KeyGenerator.GenerateHmacKey(); var keys = KeyGenerator.GenerateKeys(); var encryptor = new AsymmetricEncryptor(new AsymmetricOptions() { HmacKey = hmacKey, Key = keys.PublicKey }); const string expected = "Some test"; var encrypted = encryptor.Encrypt(expected); var decryptor = new AsymmetricEncryptor(new AsymmetricOptions() { HmacKey = hmacKey, Key = keys.PrivateKey }); var decrypted = decryptor.DecryptAsString(encrypted); Assert.Equal(expected, decrypted); }
public EncryptedCredential(string userName, string password, RSAParameters parameters) { UserName = AsymmetricEncryptor.Encrypt(userName, parameters); Password = AsymmetricEncryptor.Encrypt(password, parameters); }