Esempio n. 1
0
def encdec(machine, plaintext):
    print("----------------------------------")
    print(plaintext)
    enc = machine.encrypt(plaintext)
    print(enc)
    dec = machine.decrypt(enc)
    print(dec)


cm = CryptMachine(Rot13())

plaintext = u"The quick brown fox jumps over the lazydog."
encdec(cm, plaintext)

cm = SaveAll(cm)

plaintext = u"Why did the chicken cross the road? Gb trg gb gur bgure fvqr"
encdec(cm, plaintext)

plaintext = u"Die heiße Zypernsonne quälte Max und Victoria ja böse auf dem Weg bis zur Küste."
cm.set_alphabet(al.GERMAN)
encdec(cm, plaintext)

plaintext = u"FAQ om Schweiz: Klöv du trång pjäxby?"
cm.set_alphabet(al.SWEDISH)
encdec(cm, plaintext)

cm.set_alphabet(al.JAPANESE_HIRAGANA)
cm.set_key(1)
plaintext = u"あいうえおかきくけこがぎぐげごさしすせそざじずぜぞたちつてとだぢづでどなにぬねのはひふへほばびぶべぼぱぴぷぺぽまみむめもやゆよらりるれろわをんゃゅょぁぇ"
Esempio n. 2
0
key = 5
cm.set_key(key)
cm.set_alphabet(al.ENGLISH)
plaintext = "WE ARE DISCOVERED FLEE AT ONCE"
encdec(cm, plaintext)

cm = cm0
cm.set_alphabet(al.ENGLISH)
plaintext = "I don't love non-alphabet characters and uppercase. I will remove all of them: ^,&@$~(*;?&#."
encdec(cm, plaintext)

cm = Block(cm, length=5, sep=" ")
plaintext = "This text is divided by blocks of length 5!"
encdec(cm, plaintext)

cm = SaveAll(cm0)
plaintext = "I love non-alphabet characters. These are : ^,&@$~(*;?&#. That's it!"
encdec(cm, plaintext)

cm.set_alphabet(al.ENGLISH_SQUARE_IJ)
plaintext = "ENGLISH_SQUARE_IJ doesn't change Ii to Jj because it's a transposition cipher!"
encdec(cm, plaintext)

cm.set_alphabet(al.JAPANESE_HIRAGANA)
cm.set_key(4)
plaintext = u"text あい だやぎへぐゆぢ"
encdec(cm, plaintext)
'''
schweißgequältvomödentextzürnttypografjakob
kobagttevqewhcsiuonztrafjonxdtegßämtüypreöl
schweißgequältvomödentextzürnttypografjakob
Esempio n. 3
0
    enc = machine.encrypt(plaintext)
    print(enc)
    dec = machine.decrypt(enc)
    print(dec)


cm = UpperCase(CryptMachine(Bazeries()))
cm.set_alphabet(al.ENGLISH_SQUARE_IJ)

key = (81257, u"eightyonethousandtwohundredfiftyseven")
cm.set_key(key)
plaintext = u"Whoever has made a voyage up the Hudson" \
            u" must remember the Kaatskill mountains"
encdec(cm, plaintext)

cm = SaveAll(cm)
encdec(cm, plaintext)

cm = UpperCase(SaveAll(CryptMachine(Bazeries(), key)))
cm.set_alphabet(al.ENGLISH_SQUARE_IJ)
plaintext = u"The quick brown fox jumps over the lazy dog!"
encdec(cm, plaintext)

cm.set_alphabet(al.GREEK_SQUARE)
cm.set_key((2358, u"κλειδί"))
plaintext = u"Θέλει αρετή και τόλμη η ελευθερία. (Ανδρέας Κάλβος)"
encdec(cm, plaintext)
'''
================================================================================
Whoever has made a voyage up the Hudson must remember the Kaatskill mountains
DUMTMCDSENRTEMVEQXMOELCCRVXDMDKWXNNMUKRDKUMYNMBPRKEEPMGNGEKWXCRWB
Esempio n. 4
0
def encdec(machine, plaintext):
    print(plaintext)
    enc = machine.encrypt(plaintext)
    print(enc)
    print(machine.decrypt(enc))
    print("----------------------------------")


cm0 = CryptMachine(cipher, key)
cm = UpperCase(Block(cm0))
cm.set_alphabet(alphabet)
plaintext = u"Attack at once!"
encdec(cm, plaintext)

cm1 = SaveAll(cm0)
plaintext = u"Attack at once!"
encdec(cm1, plaintext)

alphabet = al.GERMAN_SQUARE
key = "german"
cm.set_key(key)
cm.set_alphabet(alphabet)
plaintext = u"Schweißgequält vom öden Text zürnt Typograf Jakob"
encdec(cm, plaintext)

alphabet = (
    u"uúů",
    u"aá",
    u"b",
    u"cč",
Esempio n. 5
0
    dec = machine.decrypt(enc)
    print(dec)
    print("-----------------------------------")


plaintext = u"thequickbrownfoxjumpsoverthelazydog"
key = 3
cipher = Caesar()

cm = CryptMachine(cipher, key)
encdec(cm, plaintext)

cm.set_alphabet(alphabets.GERMAN)
encdec(cm, plaintext)

cm1 = SaveAll(cm)
cm1.set_key(9)
plaintext = u"the quick brown fox jumps over the lazy dog"
encdec(cm1, plaintext)

cm2 = cm
cm2.set_cipher(Atbash())
plaintext = u"Achtung Minen"
encdec(cm2, plaintext)


'''
Output:

thequickbrownfoxjumpsoverthelazydog
wkhtxlfneurzqiramxpsvryhuwkhodcbgrj
Esempio n. 6
0
    print("=" * 80)
    print(plaintext)
    enc = machine.encrypt(plaintext)
    print(enc)
    dec = machine.decrypt(enc)
    print(dec)


key = (u"example", u"keyword", u"third")
cm = UpperCase(CryptMachine(ThreeSquare()))
cm.set_alphabet(al.ENGLISH_SQUARE_OQ)
cm.set_key(key)
plaintext = u"The quick brown fox jumps over the lazy dog!"
encdec(cm, plaintext)

cm = SaveAll(cm)
encdec(cm, plaintext)

cm = SaveAll(CryptMachine(ThreeSquare()))
cm.set_alphabet(al.ENGLISH_SQUARE_IJ)
key = (u"criptog", u"segurt", u"mars")
cm.set_key(key)
plaintext = u"Attack at dawns!!!"
encdec(cm, plaintext)

cm.set_alphabet(al.GREEK_SQUARE)
key = (u"ίκλειδ", u"κλειδί", u"λειδίκ")
cm.set_key(key)
plaintext = u"Θέλει αρετή και τόλμη η ελευθερία. (Ανδρέας Κάλβος)"
encdec(cm, plaintext)
Esempio n. 7
0

def encdec(machine, plaintext):
    print("=======================================")
    print(plaintext)
    enc = machine.encrypt(plaintext)
    print(enc)
    dec = machine.decrypt(enc)
    print(dec)


key = 5
plaintext = u"Dog jumps four times and cat six times"
print(plaintext)

cm1 = SaveAll(CryptMachine(Caesar(), key))
enc = cm1.encrypt(plaintext)
print(enc)

cm2 = SaveAll(CryptMachine(Rot13()))
enc = cm2.encrypt(enc)
print(enc)

print("=======================================")

cm = CompositeMachine(cm1)
cm.add_machines(cm2)
enc = cm.encrypt(plaintext)
print(enc)
encdec(cm, plaintext)
Esempio n. 8
0
    u"s",
    u"t",
    u"u",
    u"v",
    u"w",
    u"x",
    u"y",
    u"z",
    u"+",
)
cm1.set_alphabet(alphabet)

plaintext = u"Flygande bäckasiner söka hwila på mjuka tuvor!"
encdec(cm1, plaintext)

cm2 = SaveAll(cm)
alphabet = "felixmardstbcghjknopquvwyz+"
cm2.set_alphabet(alphabet)

plaintext = u"Aide-toi, le ciel t'aidera"
encdec(cm2, plaintext)
'''
defendtheeastwallofthecastle
suefecphsegyyjiximfofocejlrf
defendtheeastwallofthecastle
----------------------------------
Flygande bäckasiner söka hwila på mjuka tuvor!
fbiiajbmdmdsazckwpnujshvokdgpaqgackzkri
flygandebackasinersokahwilapamjukatuvor
----------------------------------
Aide-toi, le ciel t'aidera
Esempio n. 9
0
# using cryptmachine


def encdec(machine, plaintext):
    print(
        "--------------------------------------------------------------------")
    print(plaintext)
    enc = machine.encrypt(plaintext)
    print(enc)
    print(machine.decrypt(enc))


cm0 = CryptMachine(cipher, key)

plaintext = "I love non-alphabet characters. These are : ^,&@$~(*;?&#. That's it!"
cm = SaveAll(cm0)
encdec(cm, plaintext)

cm.set_alphabet(al.ENGLISH_SQUARE_IJ)
plaintext = "Jj becomes Ii because we use ENGLISH_SQUARE_IJ!"
encdec(cm, plaintext)

cm.set_alphabet(al.JAPANESE_HIRAGANA)
cm.set_key(u"だやぎへ")
plaintext = u"text あい だやぎへぐゆぢ"
encdec(cm, plaintext)

plaintext = "I don't love non-alphabet characters. I will remove all of them: ^,&@$~(*;?&#. Great!"
cm = cm0
cm.set_alphabet(al.ENGLISH)
cm.set_key(key)
Esempio n. 10
0
from secretpy import Chao, CryptMachine, alphabets
from secretpy.cmdecorators import UpperCase, SaveAll


def encdec(machine, plaintext):
    print(plaintext)
    enc = machine.encrypt(plaintext)
    print(enc)
    print(machine.decrypt(enc))
    print("-------------------------------")


alphabet = "ptlnbqdeoysfavzkgjrihwxumc"  # RIGHT WHEEL PT
key = "hxuczvamdslkpefjrigtwobnyq"  # LEFT WHEEL CT

cm = UpperCase(SaveAll(CryptMachine(Chao(), key)))
cm.set_alphabet(alphabet)

plaintext = "well done is better than well said"
encdec(cm, plaintext)

plaintext = "plaintext"
encdec(cm, plaintext)

cm.set_alphabet(alphabets.ENGLISH)
cm.set_key(alphabets.ENGLISH)
plaintext = "do not use pc"
encdec(cm, plaintext)
'''
Output:
Esempio n. 11
0
# -*- encoding: utf-8 -*-

from secretpy import Vic, CryptMachine
from secretpy.cmdecorators import SaveAll


def encdec(machine, plaintext):
    print("----------------------------------")
    print(plaintext)
    enc = machine.encrypt(plaintext)
    print(enc)
    print(machine.decrypt(enc))


key = "0452"
cm = SaveAll(CryptMachine(Vic(), key))
alphabet = [
    u"e",
    u"t",
    u"",
    u"a",
    u"o",
    u"n",
    u"",
    u"r",
    u"i",
    u"s",
    u"b",
    u"c",
    u"d",
    u"f",