예제 #1
0
    def test_changeKeyPassphrase(self):
        ck1 = CryptoKey(passphrase="pass")
        encryptedMessage = ck1.encrypt(self.testMessage)
        key = ck1.export("otherPass")

        ck2 = CryptoKey(key, "otherPass")
        self.assertEqual(self.testMessage, ck2.decrypt(encryptedMessage))
예제 #2
0
 def getPrivateKey(self, passphrase=None):
     ck = CryptoKey()
     if os.path.exists(self.privateKeyPath):
         ck.load(self.privateKeyPath, passphrase)
     else:  # if private key doesn't exist, then save generated one
         ck.save(self.privateKeyPath, passphrase)
     return ck
예제 #3
0
    def test_unicodePassphrase(self):
        unicodePassphrase = "łśźćżów~!@#$ '\"%^&*("
        ck = CryptoKey()
        msg = ck.encrypt(self.testMessage)
        key = ck.export(unicodePassphrase)

        ck2 = CryptoKey(key, unicodePassphrase)
        msg2 = ck2.encrypt(self.testMessage)
        self.assertEqual(ck.decrypt(msg), ck2.decrypt(msg2))
예제 #4
0
    def test_changeKeyPassphrase(self):
        ck1 = CryptoKey(passphrase="pass")
        encryptedMessage = ck1.encrypt(self.testMessage)
        key = ck1.export("otherPass")

        ck2 = CryptoKey(key, "otherPass")
        self.assertEqual(self.testMessage, ck2.decrypt(encryptedMessage))
예제 #5
0
    def test_unicodePassphrase(self):
        unicodePassphrase = u"łśźćżów~!@#$ '\"%^&*("
        ck = CryptoKey()
        msg = ck.encrypt(self.testMessage)
        key = ck.export(unicodePassphrase)

        ck2 = CryptoKey(key, unicodePassphrase)
        msg2 = ck2.encrypt(self.testMessage)
        self.assertEqual(ck.decrypt(msg), ck2.decrypt(msg2))
예제 #6
0
 def getPrivateKey(self, passphrase=None):
     ck = CryptoKey()
     if os.path.exists(self.privateKeyPath):
         ck.load(self.privateKeyPath, passphrase)
     else:  # if private key doesn't exist, then save generated one
         ck.save(self.privateKeyPath, passphrase)
     return ck
예제 #7
0
 def setUp(self):
     self.db = Database('sqlite://')  # in memory database
     self.db.create()
     self.ck = CryptoKey()
     self.hosts = Hosts(self.db, self.ck)
예제 #8
0
 def test_message(self):
     ck = CryptoKey()
     encryptedMsg = ck.encrypt(self.testMessage)
     self.assertEqual(ck.decrypt(encryptedMsg), self.testMessage)
예제 #9
0
 def test_unicode(self):
     unicodeMessage = "łśźćżów~!@#$ '\"%^&*("
     ck = CryptoKey()
     encryptedMsg = ck.encrypt(unicodeMessage)
     self.assertEqual(ck.decrypt(encryptedMsg), unicodeMessage)
예제 #10
0
 def test_decryptDifferentKey(self):
     ck1 = CryptoKey()
     ck2 = CryptoKey()
     encryptedMessage = ck1.encrypt(self.testMessage)
     self.assertRaises(ValueError, ck2.decrypt, encryptedMessage)
예제 #11
0
 def test_wrongPassword(self):
     ck1 = CryptoKey()
     key = ck1.export("somePass")
     self.assertRaises(ValueError, CryptoKey, key, "wrongPass")
예제 #12
0
 def test_message(self):
     ck = CryptoKey()
     encryptedMsg = ck.encrypt(self.testMessage)
     self.assertEqual(ck.decrypt(encryptedMsg), self.testMessage)
예제 #13
0
 def test_unicode(self):
     unicodeMessage = u"łśźćżów~!@#$ '\"%^&*("
     ck = CryptoKey()
     encryptedMsg = ck.encrypt(unicodeMessage)
     self.assertEqual(ck.decrypt(encryptedMsg), unicodeMessage)
예제 #14
0
 def test_decryptDifferentKey(self):
     ck1 = CryptoKey()
     ck2 = CryptoKey()
     encryptedMessage = ck1.encrypt(self.testMessage)
     self.assertRaises(ValueError, ck2.decrypt, encryptedMessage)
예제 #15
0
 def test_wrongPassword(self):
     ck1 = CryptoKey()
     key = ck1.export("somePass")
     self.assertRaises(ValueError, CryptoKey, key, "wrongPass")