예제 #1
0
from secretpy import Beaufort, CryptMachine, alphabets as al
from secretpy.cmdecorators import SaveAll


def encdec(cipher, plaintext, key, alphabet=al.ENGLISH):
    print(
        '========================================================================================'
    )
    print(plaintext)
    enc = cipher.encrypt(plaintext, key, alphabet)
    print(enc)
    print(cipher.decrypt(enc, key, alphabet))


key = "key"
cipher = Beaufort()

plaintext = u"thequickbrownfoxjumpsoverthelazydog"
encdec(cipher, plaintext, key)

alphabet = al.GERMAN
plaintext = u"schweißgequältvomödentextzürnttypografjakob"
encdec(cipher, plaintext, key, alphabet)

alphabet = al.SWEDISH
plaintext = u"faqomschweizklövdutrångpjäxby"
encdec(cipher, plaintext, key, alphabet)

# using cryptmachine

예제 #2
0
#!/usr/bin/python
# -*- encoding: utf-8 -*-

from secretpy import CryptMachine
from secretpy import Beaufort
from secretpy import alphabets

plaintext = u"helloworld"
key = "key"

cm = CryptMachine(Beaufort(), key)

print(plaintext)
enc = cm.encrypt(plaintext)
print(enc)
dec = cm.decrypt(enc)
print(dec)

print("-----------------------------------")

alphabet = alphabets.GERMAN
cm.set_alphabet(alphabet)

print(plaintext)
enc = cm.encrypt(plaintext)
print(enc)
dec = cm.decrypt(enc)
print(dec)
'''
helloworld
danzqcwnnh
예제 #3
0
 def test_decrypt(self):
     cipher = Beaufort()
     for i, alphabet in enumerate(self.alphabet):
         dec = cipher.decrypt(self.ciphertext[i], self.key[i], alphabet)
         self.assertEqual(dec, self.plaintext[i])