Tripcode decoder (696)

311 Name: Anonymous : 2007-10-21 18:34 ID:o7z1Y0zM [Del]

Python-fag here, this seems to work fairly decently for ASCII tripcodes, seeing as Albright's original Python version is nowhere to be found, so it's based on the Thorn PHP version he posted earlier.

This code probably sucks and is slow.

def tripcode(trip):

if len(trip) > 0:
salt = trip[1:3] + "H.."
kill_non_ascii = re.compile("[^\.-z]")
salt = kill_non_ascii.sub('.', salt)
replace_dict = {
":" : "A",
";" : "B",
"<" : "C",
"=" : "D",
">" : "E",
"?" : "F",
"@" : "G",
"[" : "a",
"\\" : "b",
"]" : "c",
"^" : "d",
"_" : "e",
"`" : "f",
}
for line in replace_dict:
salt = salt.replace(line, replace_dict[line])
trip = trip.encode('shift_jis', 'replace')
salt = salt.encode('shift_jis', 'replace')
result = crypt(trip, salt)[3:]
else:
result = ""
return result
This thread has been closed. You cannot post in this thread any longer.