Ejemplo n.º 1
0
    def testBadPassphrase(self):
        mgr = YokadiCryptoManager()
        mgr.force_decrypt = True  # Simulate user ask for decryption
        tui.addInputAnswers("mySecretPassphrase")
        important_sentence = "Don't tell anyone"
        encrypted_sentence = mgr.encrypt(important_sentence)

        mgr = YokadiCryptoManager()  # Define new manager with other passphrase
        mgr.force_decrypt = True  # Simulate user ask for decryption
        tui.addInputAnswers("theWrongSecretPassphrase")
        self.assertRaises(YokadiException, mgr.decrypt, encrypted_sentence)
Ejemplo n.º 2
0
    def testIfEncrypted(self):
        mgr = YokadiCryptoManager()
        mgr.force_decrypt = True  # Simulate user ask for decryption
        tui.addInputAnswers("mySecretPassphrase")
        important_sentence = "Don't tell anyone"
        encrypted_sentence = mgr.encrypt(important_sentence)
        self.assertTrue(mgr.isEncrypted(encrypted_sentence))
        self.assertFalse(mgr.isEncrypted(important_sentence))

        # Should not fail with empty data
        self.assertFalse(mgr.isEncrypted(None))
Ejemplo n.º 3
0
 def testEncrypt(self):
     mgr = YokadiCryptoManager()
     mgr.force_decrypt = True  # Simulate user ask for decryption
     tui.addInputAnswers("mySecretPassphrase")
     important_sentence = "Don't tell anyone"
     encrypted_sentence = mgr.encrypt(important_sentence)
     decrypted_sentence = mgr.decrypt(encrypted_sentence)
     self.assertEqual(important_sentence, decrypted_sentence)
     # Enter again same passphrase and check it is ok
     mgr = YokadiCryptoManager()
     tui.addInputAnswers("mySecretPassphrase")
Ejemplo n.º 4
0
 def testEncryptLongSentence(self):
     mgr = YokadiCryptoManager()
     mgr.force_decrypt = True  # Simulate user ask for decryption
     tui.addInputAnswers("mySecretPassphrase")
     important_sentence = '''This sentence is long long long long
                             This sentence is long
                             This sentence is long
                             This sentence is long
                             This sentence is long long long'''
     encrypted_sentence = mgr.encrypt(important_sentence)
     decrypted_sentence = mgr.decrypt(encrypted_sentence)
     self.assertEqual(important_sentence, decrypted_sentence)