示例#1
0
        public void CanEcryptAPrivateKey()
        {
            // password for nano produced simple wallet file
            var password = "******";

            // key to encrypt
            var privateKey = "9b4ed1b56be9e8106da2ef4fc681db0f9f4c22ccbad5f9bb9d3fbe68a1b20007";

            // iv from nano produced simple wallet file
            var iv = "d590ab155351abdd9c511e8fb46ee7a9";

            // encrypted key from nano produced wallet file
            var encryptedKey = "590c675be30dc85d2512620b0526c5ddb6756adf98ebf827f7c124e9f115a81943b741d71de4397901cdb1b917bf1d65";

            var pass = CryptoUtils.DerivePassSha(password, 20);

            var result = CryptoUtils.AesEncryptor(pass, iv.FromHex(), privateKey.FromHex());

            var encKey = new EncryptedPrivateKey(result.ToHexLower());

            Assert.AreEqual(iv, encKey.Iv);
            Assert.AreEqual(encryptedKey, encKey.EncryptedKey);
        }