Ejemplo n.º 1
0
    def test_encode_decode(self):
        n_keys = 8
        n_passwds = 8

        LEN = 12

        for keys in range(n_keys):
            length = int(random.random() * LEN)

            key = os.urandom(LEN - length).encode('hex')
            padded_key = transform_passwd(key)

            for passwds in range(n_passwds):
                passwd = os.urandom(length).encode('hex')

                original = make_gsm_dict(passwd)

                # encode
                encrypted = encryptData(padded_key, pickle.dumps(original))

                # decode
                pickledobj = decryptData(padded_key, encrypted)
                decrypted = pickle.load(StringIO(pickledobj))

                self.assertEqual(decrypted, original)
Ejemplo n.º 2
0
 def update(self, uuid, conn_id, secrets, update=True):
     path = os.path.join(self.secrets_path, uuid)
     with open(path, "w") as f:
         data = encryptData(self.key, pickle.dumps(secrets))
         f.write(data)