![]() |
|
[Source] Hazz15, Zong22, Megan35, Atom128 - Printable Version +- Sinisterly (https://sinister.ly) +-- Forum: Coding (https://sinister.ly/Forum-Coding) +--- Forum: Python (https://sinister.ly/Forum-Python) +--- Thread: [Source] Hazz15, Zong22, Megan35, Atom128 (/Thread-Source-Hazz15-Zong22-Megan35-Atom128) Pages:
1
2
|
[Source] Hazz15, Zong22, Megan35, Atom128 - Deque - 05-12-2013 You probably already encountered these odd encodings I named in the title. Searching for algorithms or explanations won't give you much information as they seem to be an invention by a single website: http://crypo.in.ua/tools/eng_atom128d.php It is amazing how many people use these encodings nevertheless. I discovered that they are only base64 variants whose characters have been substituted. Here is a Python 2.7 solution for these encodings. It calculates the base64 string and substitutes the characters afterwards to encode or vice versa to decode. Code: import base64
megan35 = "3GHIJKLMNOPQRSTUb=cdefghijklmnopWXYZ/12+406789VaqrstuvwxyzABCDEF5"
atom128 = "/128GhIoPQROSTeUbADfgHijKLM+n0pFWXY456xyzB7=39VaqrstJklmNuZvwcdEC"
zong22 = "ZKj9n+yf0wDVX1s/5YbdxSo=ILaUpPBCHg8uvNO4klm6iJGhQ7eFrWczAMEq3RTt2"
hazz15 = "HNO4klm6ij9n+J2hyf0gzA8uvwDEq3X1Q7ZKeFrWcVTts/MRGYbdxSo=ILaUpPBC5"
base = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="
class B64VariantEncoder:
def __init__(self, translation):
base = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="
self.lookup = dict(zip(base, translation))
self.revlookup = dict(zip(translation, base))
def encode(self, text):
global lookup
b64 = base64.b64encode(text)
result = "".join([self.lookup[x] for x in b64])
return result
def decode(self, code):
global revlookup
b64 = "".join([self.revlookup[x] for x in code])
result = base64.b64decode(b64)
return result
def encode(variant, text):
encoder = B64VariantEncoder(variant)
return encoder.encode(text)
def decode(variant, code):
try:
encoder = B64VariantEncoder(variant)
return encoder.decode(code)
except KeyError:
return "no valid encoding"
except TypeError:
return "no correct padding"
print "type in your string to encode/decode"
text = raw_input()
print "encode (1) or decode (2)?"
option = raw_input()
if option == "1":
print "base64:", encode(base, text)
print "atom128:", encode(atom128, text)
print "megan35:", encode(megan35, text)
print "hazz15:", encode(hazz15, text)
print "zong22:", encode(zong22, text)
elif option == "2":
print "base64:", decode(base, text)
print "atom128:", decode(atom128, text)
print "megan35:", decode(megan35, text)
print "hazz15:", decode(hazz15, text)
print "zong22:", decode(zong22, text)
else:
print "no valid option"Example output: Code: type in your string to encode/decode
by+uac1hUoWWUONrB522
encode (1) or decode (2)?
2
base64: o/�i�aR��P�k��
atom128: no correct padding
megan35: Bv���E<x <�1�@�
hazz15: no correct padding
zong22: HackcommunityNote: This is just a source sample and not meant as a full fledged application. [Source] Hazz15, Zong22, Megan35, Atom128 - Deque - 05-12-2013 You probably already encountered these odd encodings I named in the title. Searching for algorithms or explanations won't give you much information as they seem to be an invention by a single website: http://crypo.in.ua/tools/eng_atom128d.php It is amazing how many people use these encodings nevertheless. I discovered that they are only base64 variants whose characters have been substituted. Here is a Python 2.7 solution for these encodings. It calculates the base64 string and substitutes the characters afterwards to encode or vice versa to decode. Code: import base64
megan35 = "3GHIJKLMNOPQRSTUb=cdefghijklmnopWXYZ/12+406789VaqrstuvwxyzABCDEF5"
atom128 = "/128GhIoPQROSTeUbADfgHijKLM+n0pFWXY456xyzB7=39VaqrstJklmNuZvwcdEC"
zong22 = "ZKj9n+yf0wDVX1s/5YbdxSo=ILaUpPBCHg8uvNO4klm6iJGhQ7eFrWczAMEq3RTt2"
hazz15 = "HNO4klm6ij9n+J2hyf0gzA8uvwDEq3X1Q7ZKeFrWcVTts/MRGYbdxSo=ILaUpPBC5"
base = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="
class B64VariantEncoder:
def __init__(self, translation):
base = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="
self.lookup = dict(zip(base, translation))
self.revlookup = dict(zip(translation, base))
def encode(self, text):
global lookup
b64 = base64.b64encode(text)
result = "".join([self.lookup[x] for x in b64])
return result
def decode(self, code):
global revlookup
b64 = "".join([self.revlookup[x] for x in code])
result = base64.b64decode(b64)
return result
def encode(variant, text):
encoder = B64VariantEncoder(variant)
return encoder.encode(text)
def decode(variant, code):
try:
encoder = B64VariantEncoder(variant)
return encoder.decode(code)
except KeyError:
return "no valid encoding"
except TypeError:
return "no correct padding"
print "type in your string to encode/decode"
text = raw_input()
print "encode (1) or decode (2)?"
option = raw_input()
if option == "1":
print "base64:", encode(base, text)
print "atom128:", encode(atom128, text)
print "megan35:", encode(megan35, text)
print "hazz15:", encode(hazz15, text)
print "zong22:", encode(zong22, text)
elif option == "2":
print "base64:", decode(base, text)
print "atom128:", decode(atom128, text)
print "megan35:", decode(megan35, text)
print "hazz15:", decode(hazz15, text)
print "zong22:", decode(zong22, text)
else:
print "no valid option"Example output: Code: type in your string to encode/decode
by+uac1hUoWWUONrB522
encode (1) or decode (2)?
2
base64: o/�i�aR��P�k��
atom128: no correct padding
megan35: Bv���E<x <�1�@�
hazz15: no correct padding
zong22: HackcommunityNote: This is just a source sample and not meant as a full fledged application. RE: [Source] Hazz15, Zong22, Megan35, Atom128 - ArkPhaze - 05-13-2013 Well done I see you're starting to enjoy Python. It's a nice little language.
RE: [Source] Hazz15, Zong22, Megan35, Atom128 - ArkPhaze - 05-13-2013 Well done I see you're starting to enjoy Python. It's a nice little language.
RE: [Source] Hazz15, Zong22, Megan35, Atom128 - MrGeek - 05-13-2013 Thanks sis , I've seen those kind of encryption. Now I can study.
RE: [Source] Hazz15, Zong22, Megan35, Atom128 - MrGeek - 05-13-2013 Thanks sis , I've seen those kind of encryption. Now I can study.
RE: [Source] Hazz15, Zong22, Megan35, Atom128 - Deque - 05-13-2013 (05-13-2013, 07:23 AM)ArkPhaze Wrote: Well done It is nice especially to show some algorithms to others, because of it's pseudocode-like nature and some of the functional features (i.e. list comprehensions) are nice as well. But I don't really like dynamically typed languages. I feel people starting to learn programming with dynamically typed languages have a much harder time to understand what actually happens and I personally miss the documentation-part that a type declaration does. So, yes I am enjoying it, but I am also skeptic. @MrGeek: You are welcome. RE: [Source] Hazz15, Zong22, Megan35, Atom128 - Deque - 05-13-2013 (05-13-2013, 07:23 AM)ArkPhaze Wrote: Well done It is nice especially to show some algorithms to others, because of it's pseudocode-like nature and some of the functional features (i.e. list comprehensions) are nice as well. But I don't really like dynamically typed languages. I feel people starting to learn programming with dynamically typed languages have a much harder time to understand what actually happens and I personally miss the documentation-part that a type declaration does. So, yes I am enjoying it, but I am also skeptic. @MrGeek: You are welcome. RE: [Source] Hazz15, Zong22, Megan35, Atom128 - Psycho_Coder - 05-13-2013 Thanks I will be needing these specially as these fall in my line of action. It would have been better you would have posted these in java. RE: [Source] Hazz15, Zong22, Megan35, Atom128 - Psycho_Coder - 05-13-2013 Thanks I will be needing these specially as these fall in my line of action. It would have been better you would have posted these in java. |