Skip to content

Instantly share code, notes, and snippets.

@naitsric
Created January 23, 2017 19:31
Show Gist options
  • Save naitsric/0c1b86e33f505052c58bce17914455c5 to your computer and use it in GitHub Desktop.
Save naitsric/0c1b86e33f505052c58bce17914455c5 to your computer and use it in GitHub Desktop.
test, encrypt and decrypt
import math
def encrypt(text):
total_sum = 0
total_cnt = 0
for c in text:
total_cnt += 1
total_sum += ord(c) ** total_cnt
print(total_sum)
return total_cnt, total_sum
def decrypt(total_cnt, total_sum):
cnt = total_cnt
text = []
total_subs = total_sum
while cnt != 0:
c = math.pow(total_subs, 1 / cnt)
text.append(chr(int(c)))
total_subs -= int(c) ** cnt
cnt -= 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment