Пример #1
0
def test_multiline_input():
    emojifier = emoji_it()
    expected = ["And if you sing", "though as angels"]
    input_lines = ['🙈🍶🤣 🏉🌹 📜🥪🏫 🎷🏉🍶🏵', '🧣📍🥪🏫🏵📍 🚀🎷 🚀🍶🏵🐓😥🎷']

    for i in range(len(expected)):
        assert emojifier.decrypt(input_lines[i]) == expected[i]
Пример #2
0
def encrypt():
    form = EncryptForm()
    if form.validate_on_submit():

        #received message from form

        message = form.message.data
        multiplier = form.multiplier.data
        # choice = form.key.data
        # options = {u'U+1F680' : ':rocket:', u'U+1F4DC' : ':scroll:')}
        key = form.key.data

        #instantiate class
        emoji_encrypt_class = emoji_it()

        #rewrite message with encrypted message
        emoji_encrypt_class.emoji_key = key
        emoji_encrypt_class.multiplier = multiplier
        message = emoji_encrypt_class.encrypt(message)

        flash('Successfully encrypted!')

        return render_template('encrypt.html', form=form, message=message)

    return render_template('encrypt.html', form=form)
Пример #3
0
def encrypt():
    form = EncryptForm()
    if form.validate_on_submit():

        #received message from form

        message = form.message.data
        multiplier = form.multiplier.data
        # choice = form.key.data
        # options = {u'U+1F680' : ':rocket:', u'U+1F4DC' : ':scroll:')}
        key = form.key.data

        #instantiate class
        emoji_encrypt_class = emoji_it()

        #rewrite message with encrypted message
        emoji_encrypt_class.emoji_key = key
        emoji_encrypt_class.multiplier = multiplier
        message = emoji_encrypt_class.encrypt(message)

        flash('Successfully encrypted!')

        return render_template('encrypt.html', form=form, message=message)

    return render_template('encrypt.html', form=form)
Пример #4
0
def test_cipher_duplicate():
    cipher = emoji_it()
    cipher.multiplier = 26

    #create cipher dictionary
    cipher_dict = cipher.define_cipher()

    for value in cipher_dict.values():
        counter = 0

        for value2 in cipher_dict.values():
            if value == value2:
                counter += 1

        assert counter == 1  #value should only match value2 once per iteration
Пример #5
0
def test_cipher_duplicate():
    cipher = emoji_it()
    cipher.multiplier = 26 

    #create cipher dictionary
    cipher_dict = cipher.define_cipher()
    
    for value in cipher_dict.values():
        counter = 0

        for value2 in cipher_dict.values():
            if value == value2:
                counter += 1
        
        assert counter == 1 #value should only match value2 once per iteration
Пример #6
0
def game():
    json_url = os.path.join(os.path.realpath(os.path.dirname(__file__)), "static", "puzzles.json")
    puzzles = json.load(open(json_url))

    puzzle_index = random.randint(0, len(puzzles) - 1)
    puzzle = puzzles[puzzle_index]

    #hot swap the 'encrypted' message.
    message = puzzle['decrypted']
    multiplier = random.randint(1, 100)

    emoji_encrypt_class = emoji_it()
    emoji_encrypt_class.multiplier = multiplier
    message = emoji_encrypt_class.encrypt(message)

    puzzle['encrypted'] = message

    return render_template('game.html', puzzle=puzzle)
Пример #7
0
def game():
    json_url = os.path.join(os.path.realpath(os.path.dirname(__file__)),
                            "static", "puzzles.json")
    puzzles = json.load(open(json_url))

    puzzle_index = random.randint(0, len(puzzles) - 1)
    puzzle = puzzles[puzzle_index]

    #hot swap the 'encrypted' message.
    message = puzzle['decrypted']
    multiplier = random.randint(1, 100)

    emoji_encrypt_class = emoji_it()
    emoji_encrypt_class.multiplier = multiplier
    message = emoji_encrypt_class.encrypt(message)

    puzzle['encrypted'] = message

    return render_template('game.html', puzzle=puzzle)
Пример #8
0
def test_decryption_2():
    emojifier = emoji_it()
    assert emojifier.decrypt('🏫⛵ ! ?') == "um ! ?"
Пример #9
0
def test_encryption_2():
    emojifier = emoji_it()
    assert emojifier.encrypt("um ! ?") == '🏫⛵ ! ?'
Пример #10
0
def test_default_sanity():
    cipher = emoji_it()

    assert cipher.emoji_key == ':rocket:'
    assert cipher.multiplier == 1
Пример #11
0
def test_encryption_1():
    emojifier = emoji_it()
    assert emojifier.encrypt("hello") == '📍🐓😥😥🥪'
Пример #12
0
def test_multiline_input():
    emojifier = emoji_it()
    input = "You work that you may keep pace\nwith the earth\nand the soul of the earth."
    expected_output = "🔀🥪🏫 ✂🥪🦕👟 🧣📍🚀🧣 📜🥪🏫 ⛵🚀📜 👟🐓🐓🛰 🛰🚀🎢🐓\n✂🏉🧣📍 🧣📍🐓 🐓🚀🦕🧣📍\n🚀🍶🤣 🧣📍🐓 🎷🥪🏫😥 🥪🌹 🧣📍🐓 🐓🚀🦕🧣📍."

    assert emojifier.encrypt(input) == expected_output
Пример #13
0
def test_numbers():
    emojifier = emoji_it()
    assert emojifier.encrypt("806-672-3455") == '⛷🤘🕡-🕡🕕🤘🏻-🤘🏾🤘🏼🤘🏽🤘🏽'
Пример #14
0
def test_empty_input():
    emojifier = emoji_it()
    assert emojifier.encrypt('') == ''
Пример #15
0
def test_chinese_korean():
    emojifier = emoji_it()
    assert emojifier.encrypt("漢字ㄲ, ㄸ, ㅃ, ㅆ, ㅉ") == '漢字ㄲ, ㄸ, ㅃ, ㅆ, ㅉ'
Пример #16
0
def test_default_sanity():
    cipher = emoji_it()

    assert cipher.emoji_key == ':rocket:'
    assert cipher.multiplier == 1
Пример #17
0
def test_de_nonAlphabet_or_numbers():
    emojifier = emoji_it()
    assert emojifier.decrypt(
        "!!!, @, #, $, % ^ & * () _ + - ` ; ' . , / ? | [ ] { } "
    ) == "!!!, @, #, $, % ^ & * () _ + - ` ; ' . , / ? | [ ] { } "
Пример #18
0
def test_decryption_1():
    emojifier = emoji_it()
    assert emojifier.decrypt('📍🐓😥😥🥪') == 'hello'
Пример #19
0
def test_de_numbers():
    emojifier = emoji_it()
    assert emojifier.decrypt('⛷🤘🕡-🕡🕕🤘🏻-🤘🏾🤘🏼🤘🏽🤘🏽') == "806-672-3455"