public void Should_VerifySignautre_With_PublicKey(string signature, string publicKeyJson) { var rsaCrypto = new RsaBcCrypto(); var verified = rsaCrypto.VerifySignature(_plainText, signature, publicKeyJson); verified.Should().BeTrue(); }
public void Should_SignData_With_PrivateKey(string privateKeyJson) { var rsaCrypto = new RsaBcCrypto(); var signature = rsaCrypto.SignData(_plainText, privateKeyJson); signature.Should().NotBeNullOrWhiteSpace(); signature.Should().NotBe(_plainText); }
public void Should_Decrypt_CipherText_With_PrivateKey(string cipherText, string privateKeyJson) { var rsaCrypto = new RsaBcCrypto(); var decrypted = rsaCrypto.Decrypt(cipherText, privateKeyJson); decrypted.Should().NotBeNullOrWhiteSpace(); decrypted.Should().Be(_plainText); }
public void Should_Encrypt_PlainText_With_PublicKey(string publicKeyJson) { var rsaCrypto = new RsaBcCrypto(); var encrypted = rsaCrypto.Encrypt(_plainText, publicKeyJson); encrypted.Should().NotBeNullOrWhiteSpace(); encrypted.Should().NotBe(_plainText); }
public void Should_Generate_KeyPair() { var rsaCrypto = new RsaBcCrypto(); var(privateKeyJson, publicKeyJson) = rsaCrypto.GenerateKeyPair(2048); privateKeyJson.Should().NotBeNullOrWhiteSpace(); publicKeyJson.Should().NotBeNullOrWhiteSpace(); }
public void Should_Encrypt_And_Decrypt_With_Generated_Key() { var rsaCrypto = new RsaBcCrypto(); var(privateKeyJson, publicKeyJson) = rsaCrypto.GenerateKeyPair(2048); var encrypted = rsaCrypto.Encrypt(_plainText, publicKeyJson); encrypted.Should().NotBeNullOrWhiteSpace(); encrypted.Should().NotBe(_plainText); var decrypted = rsaCrypto.Decrypt(encrypted, privateKeyJson); decrypted.Should().NotBeNullOrWhiteSpace(); decrypted.Should().Be(_plainText); }