Exemple #1
0
 def testNewFile(self):
     with tempfile.TemporaryDirectory() as d:
         veiled, unveiled = (os.path.join(d, f) for f in
                 ('veiled', 'unveiled'))
         passwd = 'pa-ss'
         main.makeNewVeil(veiled, passwd)
         main.decrypt(veiled, unveiled, passwd)
         self.assertEqual(os.lstat(unveiled).st_size, 0)
Exemple #2
0
 def decrypt(self):
     key = self.enterKey().encode()
     entry.decrypt(self.fileName, key)
     self.fileName = self.fileName[:-4]
     self.addRecent()
     self.readRecent()
     self.searchBar.setText("")
     self.fileName = ""
Exemple #3
0
    def testEncryptDecrypt(self):
        with tempfile.TemporaryDirectory() as d:
            orig, veiled, unveiled = (os.path.join(d, f) for f in
                    ('orig', 'veiled', 'unveiled'))
            message = 'Hello\nworld!'
            passwd = 'The veil of Ignorance'

            with open(orig, 'w', encoding='utf-8') as f:
                f.write(message)
            main.encrypt(orig, veiled, passwd)
            main.decrypt(veiled, unveiled, passwd)

            with open(unveiled, 'rb') as f:
                self.assertEqual(f.read(), message.encode('utf-8'))

            with open(veiled, 'rb') as f:
                self.assertNotEqual(f.read(), message.encode('utf-8'))
Exemple #4
0
 def test_decrypted(self):
     msg = [
         '83c297bfb0028bd3901ac5aaa88e9f449af50f12c2f43a5f61d9765e7beb2469',
         '519fac1f8ac05fd12f0cbd7aa46793210988a470d27385f6ae10518a0c6f2dd6',
         '2bda0d9c8c78cb5ec2f8c038671ddffc1a96b5d42004104c551e8390fbf4c42e'
     ]
     key = "814a8c2282ca8f4d0f2b2b72dfeeee6e5e3d8f438c039bdb5d059550739fdcec"
     p = "9240633d434a8b71a013b5b00513323f"
     q = "f870cfcd47e6d5a0598fc1eb7e999d1b"
     self.assertEqual(6, main.decrypt(int(p, 16) * int(q, 16), key, msg))
 def test_decrypt(self):
     self.assertEqual(
         main.decrypt('FFFFFFFFGFDDXGDAXDXGGXGX', key='BATTLE'),
         'ATTACKATDAWN')
 def test_decrypt(self):
     self.assertEqual(decrypt('1 2'), '12')
Exemple #7
0
 def test_decrypt(self):
     self.assertEqual(100, main.decrypt(26118, 80, 187, 180))
 def test_decrypt1(self):
     self.assertEqual(main.decrypt('AAXXDGDDXDFGXXGXGAXD', key='HI'),
                      'HELLOWORLD')
Exemple #9
0
 def test_decrypt(self):
     plaintext = decrypt(self.key, self.cipher)
     self.assertEqual(plaintext, self.plaintext)
Exemple #10
0
 def test_other_decrypt(self):
     self.assertEqual(15232, main.decrypt(2747997353, 31536, 126869, 53022))
Exemple #11
0
def test_update_password():
    site = 'LwAhR'
    master = 1234
    new_password = random.randint(1, 10000)
    update_password(master, site, new_password, db=dby)
    assert decrypt(master, site, db=dby) == str(new_password)
def test_decrypt():
    text = 'th3s 3s 1 m2ss1g2.'
    codes = {"a": "1", "e": "2", "i": "3", "o": "4", "u": "5"}
    assert main.decrypt(text, codes) == "this is a message."
Exemple #13
0
 def test_decrypt(self):
     cipher = 'Фэзыя йз зьи ахлш пвёнлш чугрщцкфнлш дцосн, жг еютзм ъгб.'
     self.assertEqual(
         main.decrypt(cipher, key=3),
         'Съешь же ещё этих мягких французских булок, да выпей чаю.')
Exemple #14
0
def test_encrypt_decrypt():
    master = 1234
    site = random_char(5)
    site_password = 4444
    encrypt(master, site, site_password, db=dby)
    assert decrypt(master, site, db=dby) == str(site_password)
 def test2_decrypt(self):
     self.assertEqual(decrypt('0482 1593 2604 3715'), '0123456789012345')
 def test1_decrypt(self):
     self.assertEqual(decrypt('пт рм ии вр е!'), 'приветмир!')
Exemple #17
0
from main import decrypt

print('从 "密文.txt" 中读取被加密的文本...')

encrypted_text = None
with open('密文.txt', 'rb') as f:
    encrypted_text = str(f.read(), 'utf-8')
print('"密文.txt"读取成功!')
# print('被加密的文本是:')
# print(encrypted_text)

plain_bytes = decrypt(encrypted_text)
plain_text = str(plain_bytes, encoding='utf-8')
print()
print('成功还原隐写信息!')
print('隐写入的文本信息是:')
print(plain_text)

print()
with open('明文.txt', 'wb') as f:
    f.write(plain_bytes)
print('已经将上述还原出的隐写信息存入"明文.txt!"')
Exemple #18
0
 def test_decrypt_abc_should_return_xyz(self):
     test_input = 'abc'
     expected = 'xyz'
     self.assertEqual(decrypt(test_input), expected)
Exemple #19
0
 def test_decrypt_def_should_return_abc(self):
     test_input = 'def'
     expected = 'abc'
     self.assertEqual(decrypt(test_input), expected)