Skip to content

Instantly share code, notes, and snippets.

@DanyelMorales
Last active May 5, 2018 15:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DanyelMorales/c02af49d47fb4aa82afd58dfae1bf3ed to your computer and use it in GitHub Desktop.
Save DanyelMorales/c02af49d47fb4aa82afd58dfae1bf3ed to your computer and use it in GitHub Desktop.
Python3 custom encode algorithm using mathematical logarithms (highly insecure)
import math
import base64
import functools
text="hola";
base=len(text);
acum=[];
for x in text:
mychr=math.log(ord(x), base);
encoded=str(mychr);
enc2="";
for y in encoded.split('.') :
enc2 += y + "@"
acum.append(enc2);
b64encoded=base64.b64encode(functools.reduce(lambda x,y: x+"###"+y, acum).encode('ascii'))
print(b64encoded);
# b'M0AzNTAyMTk4NTkwNzA1NDZAIyMjM0AzOTcyMDc5MzMxNzUwNTNAIyMjM0AzNzc0NDM3NTEwODE3MzQ2QCMjIzNAMjk5OTU2NDIxMDkzNTY0QA=='
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment