Ejemplo n.º 1
0
        public void RSACrypto_EncryptDecrypt_ReturnsCorrectResult()
        {
            var(pk, p) = this.GeneratePublicPrivateKeys();
            var sut      = new RSACrypto(pk, p);
            var expected = Guid.NewGuid().ToString();

            var cipher = sut.EncryptData(expected);
            var actual = sut.DecryptDataToString(cipher);

            Assert.Equal(expected, actual);
        }
Ejemplo n.º 2
0
        public void RSACrypto_TamperCipher_ThrowsException()
        {
            var(pk, p) = this.GeneratePublicPrivateKeys();
            var sut      = new RSACrypto(pk, p);
            var expected = Guid.NewGuid().ToString();

            var cipher = sut.EncryptData(expected);

            cipher[0]++;
            Assert.ThrowsAny <SystemException>(() => sut.DecryptDataToString(cipher));
        }