Beispiel #1
0
 def encrypt_wif(self, wif):
     """ Encrypt a wif key
     """
     if self.locked():
         raise AssertionError()
     return format(
         bip38.encrypt(PrivateKey(wif, prefix=self.prefix), self.masterpassword), "encwif")
Beispiel #2
0
    def encrypt(self, wif):
        """ Encrypt the content according to BIP38

            :param str wif: Unencrypted key
        """
        if not self.unlocked():
            raise WalletLocked
        return format(bip38.encrypt(str(wif), self.masterkey), "encwif")
Beispiel #3
0
 def test_encrypt(self):
     self.assertEqual([
         format(
             encrypt(
                 PrivateKey(
                     "5HqUkGuo62BfcJU5vNhTXKJRXuUi9QSE6jp8C3uBJ2BVHtB8WSd"),
                 "TestingOneTwoThree"), "encwif"),
         format(
             encrypt(
                 PrivateKey(
                     "5KN7MzqK5wt2TP1fQCYyHBtDrXdJuXbUzm4A9rKAteGu3Qi5CVR"),
                 "TestingOneTwoThree"), "encwif"),
         format(
             encrypt(
                 PrivateKey(
                     "5HtasZ6ofTHP6HCwTqTkLDuLQisYPah7aUnSKfC7h4hMUVw2gi5"),
                 "Satoshi"), "encwif")
     ], [
         "6PRN5mjUTtud6fUXbJXezfn6oABoSr6GSLjMbrGXRZxSUcxThxsUW8epQi",
         "6PRVWUbkzzsbcVac2qwfssoUJAN1Xhrg6bNk8J7Nzm5H7kxEbn2Nh2ZoGg",
         "6PRNFFkZc2NZ6dJqFfhRoFNMR9Lnyj7dYGrzdgXXVMXcxoKTePPX1dWByq"
     ])