Esempio n. 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]
Esempio n. 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)
Esempio n. 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)
Esempio n. 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
Esempio n. 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
Esempio n. 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)
Esempio n. 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)
Esempio n. 8
0
def test_decryption_2():
    emojifier = emoji_it()
    assert emojifier.decrypt('πŸ«β›΅ ! ?') == "um ! ?"
Esempio n. 9
0
def test_encryption_2():
    emojifier = emoji_it()
    assert emojifier.encrypt("um ! ?") == 'πŸ«β›΅ ! ?'
Esempio n. 10
0
def test_default_sanity():
    cipher = emoji_it()

    assert cipher.emoji_key == ':rocket:'
    assert cipher.multiplier == 1
Esempio n. 11
0
def test_encryption_1():
    emojifier = emoji_it()
    assert emojifier.encrypt("hello") == 'πŸ“πŸ“πŸ˜₯πŸ˜₯πŸ₯ͺ'
Esempio n. 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
Esempio n. 13
0
def test_numbers():
    emojifier = emoji_it()
    assert emojifier.encrypt("806-672-3455") == 'β›·πŸ€˜πŸ•‘-πŸ•‘πŸ••πŸ€˜πŸ»-🀘🏾🀘🏼🀘🏽🀘🏽'
Esempio n. 14
0
def test_empty_input():
    emojifier = emoji_it()
    assert emojifier.encrypt('') == ''
Esempio n. 15
0
def test_chinese_korean():
    emojifier = emoji_it()
    assert emojifier.encrypt("ζΌ’ε­—γ„², γ„Έ, γ…ƒ, γ…†, γ…‰") == 'ζΌ’ε­—γ„², γ„Έ, γ…ƒ, γ…†, γ…‰'
Esempio n. 16
0
def test_default_sanity():
    cipher = emoji_it()

    assert cipher.emoji_key == ':rocket:'
    assert cipher.multiplier == 1
Esempio n. 17
0
def test_de_nonAlphabet_or_numbers():
    emojifier = emoji_it()
    assert emojifier.decrypt(
        "!!!, @, #, $, % ^ & * () _ + - ` ; ' . , / ? | [ ] { } "
    ) == "!!!, @, #, $, % ^ & * () _ + - ` ; ' . , / ? | [ ] { } "
Esempio n. 18
0
def test_decryption_1():
    emojifier = emoji_it()
    assert emojifier.decrypt('πŸ“πŸ“πŸ˜₯πŸ˜₯πŸ₯ͺ') == 'hello'
Esempio n. 19
0
def test_de_numbers():
    emojifier = emoji_it()
    assert emojifier.decrypt('β›·πŸ€˜πŸ•‘-πŸ•‘πŸ••πŸ€˜πŸ»-🀘🏾🀘🏼🀘🏽🀘🏽') == "806-672-3455"