示例#1
0
def encrypt():
    text = request.form['text']
    rot = int(request.form['rot'])
    mess = ''
    for letter in text:
        letter = rotate_character(letter,rot)
        mess += letter
    return form.format(mess)
示例#2
0
def encrypt():
    rot = request.form["rot"]
    text = request.form["text"]
    sentence = ''
    for char in text:
        new_val = rotate_character(char, rot)
        sentence = sentence + new_val

    return form.format(sentence)
示例#3
0
def encrypt():
    rot = int(request.form['rot'])
    text = request.form['text']
    encrypted_string = ''

    for char in text:
        encrypted_string = encrypted_string + rotate_character(char, rot)

    return form.format(encrypted_string)
示例#4
0
def encrypt(text, word):
	n_encrypt = ''
	n_list = []
	z = 0
	for char in range(len(text)):
		for l in word:
			n_list.append(l)
	for char in text:
		keyletter = n_list[z]
		keyvalue = alphabet_position(keyletter)
		if char.isalpha() == True:
			x = rotate_character(char, keyvalue)
			n_encrypt += str(x)
			z += 1
		else:
			v = rotate_character(char, keyvalue)
			n_encrypt += str(v)
	return n_encrypt
示例#5
0
def encrypt():
    text = request.form['text']
    rot = int(request.form['rot'])
    new_str = ""
    for i in range(len(text)):
        if text[i].isalpha():
            new_str = new_str + rotate_character(text[i], rot)
        else:
            new_str = new_str + text[i]
    return header + body.format(new_str) + footer
示例#6
0
def Vigenere(text, key):
    newMessage = ""
    k = []
    z = 0
    count = 0
    for i in range(len(text)):
        for j in key:
            k.append(j)
    for jj in text:
        zz = k[z]
        y = alphabet_position(zz)
        if jj != " " and jj != "," and jj != "?" and jj != "." and jj != "!":
            x = rotate_character(jj, y)
            newMessage += x
            z += 1
        elif jj == " " or jj == "." or jj == "!" or jj == "," or jj == "?":
            x = rotate_character(jj, y)
            newMessage += x

    return newMessage
示例#7
0
def encrypt(text, key):
    i = 0
    key_mod = len(key)
    ciphertext = ''
    for char in text:
        if char.isalpha():
            ciphertext += rotate_character(char, alphabet_position(key[i]))
            i = (i + 1) % key_mod
        else:
            ciphertext += char
    return ciphertext
示例#8
0
文件: main.py 项目: Phaysik/LC101
def encrypt():
    # Get the values from the two form inputs
    rotate = request.form['rot']
    text = request.form['text']
    newString = ''

    # Rotate character
    for char in text:
        newString += rotate_character(char, int(rotate))

    return form.format(newString)
示例#9
0
def encrypt():
    message = ''
    rotate_by = request.form['rot']
    text = request.form['text']
    for char in text:
        if char.isalpha():
            message += rotate_character(char, rotate_by)
        else:
            message += char

    return form.format(m=message)
示例#10
0
def decrypt(ciphertext, key):
    i = 0
    key_mod = len(key)
    original = ''
    for char in ciphertext:
        if char.isalpha():
            original_shift = alphabet_position(key[i])
            original += rotate_character(char, -original_shift)
            i = (i + 1) % key_mod
        else:
            original += char
    return original
示例#11
0
def encrypt():
    new_text = ""
    text = request.form["text"]
    rot = request.form["rot"]
    for i in text:
        if i.isalpha():
            x = rotate_character(i, int(rot))
            new_text += x

        else:
            new_text += i

    return form.format(new_text)
示例#12
0
def encrypt():
    rot = request.form ['rot']
    rot = int(rot)
    text = request.form ['text']
    text = str(text)

    encrypted = ""
    for each_char in text:
        if each_char == '':
            encrypted = encrypted + ''
        else:
            each_char = rotate_character(each_char,rot)
            encrypted = encrypted + str(each_char)

    return '<h1>'+form.format(encrypted)+'</h1>'  
示例#13
0
def encrypt():
    message = ''
    try:
        rotate_by = int(request.form['rot'])
    except:
        #rotate_by = 0
        return "Rotate was not an integer."

    text = request.form['text']
    for char in text:
        if char.isalpha():
            message += rotate_character(char, rotate_by)
        else:
            message += char

    return form.format(message)
示例#14
0
def encrypt():
    rotate = int(request.form['rot'])
    maintext = request.form['text']
    returnrotation = rotate_character(maintext, rotate)
    return '<h1>' + returnrotation + '</h1>'