public void GivenImportedKey_WhenEncryptingData_ThenEncryptsData_WithImportedKey()
        {
            var expectedMessage      = "hello world";
            var expectedMessageBytes = Encoding.UTF8.GetBytes(expectedMessage);

            RSAEncryption originalRSAEncryption = RSAEncryption.CreateContainer("SomeContainer");

            var exportedPublicKey = originalRSAEncryption.ExportKey(false);

            var rsaEncryptionWithImportedKey = RSAEncryption.CreateWithKey(exportedPublicKey);

            var encryptedMessageBytes = rsaEncryptionWithImportedKey.EncryptData(expectedMessageBytes);

            var actualMessage = Encoding.UTF8.GetString(originalRSAEncryption.DecryptData(encryptedMessageBytes));

            Assert.That(actualMessage, Is.EqualTo(expectedMessage));
        }
Exemplo n.º 2
0
 public static HybridDecryption Create(string containerName, string signaturePublicKey)
 {
     return(new HybridDecryption(RSAEncryption.LoadContainer(containerName),
                                 new AESEncryption(),
                                 RSAEncryption.CreateWithKey(signaturePublicKey)));
 }
Exemplo n.º 3
0
 public static HybridEncryption Create(string publicKey, string signatureContainer)
 {
     return(new HybridEncryption(RSAEncryption.CreateWithKey(publicKey),
                                 new AESEncryption(),
                                 RSAEncryption.LoadContainer(signatureContainer)));
 }