Ejemplo n.º 1
0
    def save_key(self, password):
        key_file = os.path.join(self._config, 'secret.key')

        data = self._private_key.encode(encoder=nacl.encoding.Base64Encoder)
        ch = CryptoHelper()
        encrypted_secret = ch.encrypt(data, password, self._account_id)

        with open(key_file, 'wb') as f:
            f.write(bytes(encrypted_secret))
Ejemplo n.º 2
0
    def save_key(self, password):
        key_file = os.path.join(self._config, 'secret.key')

        data = self._private_key.encode(encoder=nacl.encoding.Base64Encoder)
        ch = CryptoHelper()
        encrypted_secret = ch.encrypt(data, password, self._account_id)

        with open(key_file, 'wb') as f:
            f.write(bytes(encrypted_secret))
Ejemplo n.º 3
0
    def load_key(self, password):
        key_file = os.path.join(self._config, 'secret.key')

        data = None
        with open(key_file, 'r') as f:
            data = f.readline()

        ch = CryptoHelper()
        secret_key = ch.decrypt(data, password, self._account_id)
        self.load_secret_key(secret_key)
Ejemplo n.º 4
0
    def load_key(self, password):
        key_file = os.path.join(self._config, 'secret.key')

        data = None
        with open(key_file, 'r') as f:
            data = f.readline()

        ch = CryptoHelper()
        secret_key = ch.decrypt(data, password, self._account_id)
        self.load_secret_key(secret_key)
Ejemplo n.º 5
0
 def _decrypt(self, data):
     salt = 'this must be rethinked!'
     ch = CryptoHelper()
     return ch.decrypt(data, self._key, salt)
Ejemplo n.º 6
0
 def _encrypt(self, data):
     # maybe base this on a random string created along the vault
     salt = 'this must be rethinked!'
     ch = CryptoHelper()
     return ch.encrypt(data, self._key, salt)