# GGearing# Simple encryption script for text# This was one my first versions of this script# 09/07/2017from __future__ import print_functionimport mathtry:input = raw_inputexcept NameError:passkey = int(math.pi * 1e14)text = input("Enter text: ")values = reverse = []def encryptChar(target):# encrytion algorithmtarget = (((target + 42) * key) - 449)return targetdef decryptChar(target):target = (((target + 449) / key) - 42)return targetdef encrypt(input_text):col_values = []for inp in input_text:current = ord(inp)current = encryptChar(current)col_values.append(current)return col_valuesdef decrypt(enc_text):col_values = []for enc in enc_text:current = int(decryptChar(enc))current = chr(current)col_values.append(current)return col_valuesdef readAndDecrypt(filename):file = open(filename, "r")data = file.read()datalistint = []actualdata = []datalist = data.split(" ")datalist.remove('')datalistint = [float(data) for data in datalist]for data in datalist:current1 = int(decryptChar(data))current1 = chr(current1)actualdata.append(current1)file.close()return actualdatadef readAndEncrypt(filename):file = open(filename, "r")data = file.read()datalist = list(data)encrypted_list = list()encrypted_list_str = list()for data in datalist:current = ord(data)current = encryptChar(current)encrypted_list.append(current)file.close()return encrypted_listdef readAndEncryptAndSave(inp_file, out_file):enc_list = readAndEncrypt(inp_file)output = open(out_file, "w")for enc in enc_list:output.write(str(enc) + " ")output.close()def readAndDecryptAndSave(inp_file, out_file):dec_list = readAndDecrypt(inp_file)output = open(out_file, "w")for dec in dec_list:output.write(str(dec))output.close()# encryptionfor t in text:current = ord(t)current = encryptChar(current)values.append(current)# decryptionfor v in values:current = int(decryptChar(v))current = chr(current)reverse.append(current)print(reverse)# saves encrypted in txt fileoutput = open("encrypted.txt", "w")for v in values:output.write(str(v) + " ")output.close()# read and decryptsprint(readAndDecrypt("encrypted.txt"))
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。