Ejemplo n.º 1
0
        public void DecryptTest(PrivateKey key, string pass, string encryptedComp, string encryptedUnComp)
        {
            using BIP0038 bip = new BIP0038();
            PrivateKey actualKey  = bip.Decrypt(encryptedComp, pass, out bool isComp1);
            PrivateKey actualKey2 = bip.Decrypt(encryptedUnComp, pass, out bool isComp2);

            Assert.True(isComp1);
            Assert.False(isComp2);

            byte[] expected = key.ToBytes();
            Assert.Equal(expected, actualKey.ToBytes());
            Assert.Equal(expected, actualKey2.ToBytes());
        }
Ejemplo n.º 2
0
        public void Decrypt_FormatExceptionTest(string encrypted, string expError)
        {
            using BIP0038 bip = new BIP0038();
            Exception ex = Assert.Throws <FormatException>(() => bip.Decrypt(encrypted, "wrong pass!", out _));

            Assert.Contains(expError, ex.Message);
        }
Ejemplo n.º 3
0
        public void Decrypt_DisposedExceptionTest()
        {
            BIP0038 bip = new BIP0038();

            bip.Dispose();
            Assert.Throws <ObjectDisposedException>(() => bip.Decrypt("aa", "", out bool isComp));
        }
Ejemplo n.º 4
0
        public void Decrypt_NullExceptionTest()
        {
            using BIP0038 bip = new BIP0038();
            string nstr = null;

            byte[] nba = null;

            Assert.Throws <ArgumentNullException>(() => bip.Decrypt(null, "", out bool isComp));
            Assert.Throws <ArgumentNullException>(() => bip.Decrypt(" ", "", out bool isComp));
            Assert.Throws <ArgumentNullException>(() => bip.Decrypt(null, new byte[1], out bool isComp));
            Assert.Throws <ArgumentNullException>(() => bip.Decrypt(" ", new byte[1], out bool isComp));
            Assert.Throws <ArgumentNullException>(() => bip.Decrypt("aaa", nstr, out bool isComp));
            Assert.Throws <ArgumentNullException>(() => bip.Decrypt("aaa", nba, out bool isComp));
        }