예제 #1
0
파일: models.py 프로젝트: pwplus/canary
    def generate(cls, obj, fingerprint):
        """Generate a challenge and return the hash of the challenge and 
        the challenge encrypted with GPG.
        """
        secret = os.urandom(16).encode("hex")
        hash = hashlib.sha256(secret).hexdigest()
        ciphertext = gpg.encrypt(secret, fingerprint)

        chal = Challenge(hash)
        db_session.add(chal)
        db_session.commit()
        obj.chal_id = chal.id
        db_session.commit()
        return ciphertext
예제 #2
0
파일: gpg_test.py 프로젝트: pwplus/canary
 def test_encrypt(self):
     """Test the encrypt function"""
     ciphertext = gpg.encrypt('test', self.fp)
     self.assertIn('-----BEGIN PGP MESSAGE-----', str(ciphertext))