Created
November 23, 2017 19:16
-
-
Save Gabriellpweb/08b91656771ab4cf29e54eb980225010 to your computer and use it in GitHub Desktop.
B64Cypher
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
__author__ = "Gabriel Luiz Pereira <[email protected]>" | |
from base64 import b64encode, b64decode | |
class B64Cypher: | |
def __init__(self, salt, iterations): | |
self.salt = salt | |
self.iterations = range(0, iterations) | |
def encode(self, text): | |
for i in self.iterations: | |
text = base64.b64encode(text+self.salt) | |
return text | |
def decode(self, text): | |
rsalt = self.salt[::-1] | |
for i in self.iterations: | |
text = (base64.b64decode(text))[:-(len(self.salt))] | |
return text | |
b64c = B64Cypher('mys41t', 4) | |
text = b64c.encode('teste') | |
print text | |
print b64c.decode(text) | |
# >>> output | |
# V2tWa1YyVnRVa2hXYmxKc1YwVXdkMVJXYUZKUVZ6RTFZM3BSZUdSQlBUMXRlWE0wTVhRPW15czQxdA== | |
# teste |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment