This code works fine but what I need is to reverse the algorithm somehow. Is there a simple solution to this? I would need to take numbers in the format as the printed out answer and have them reversed so the code would print out the answer in the format as the 'serial numbers' are in:
Expand|Select|Wrap|Line Numbers
- from hashlib import md5
- evalCrossTotal = lambda strMD5: sum(map(lambda x: int(x, 16), strMD5))
- def encryptString(strString, strPassword):
- # strString is the content of the entire file with serials
- strPasswordMD5 = md5(strPassword).hexdigest()
- intMD5Total = evalCrossTotal(strPasswordMD5)
- arrEncryptedValues = []
- for i in range(len(strString)):
- arrEncryptedValues.append(
- str(ord(strString[i]) + int(strPasswordMD5[i%32], 16) - intMD5Total)
- )
- intMD5Total = evalCrossTotal(
- md5(strString[0:i+1]).hexdigest()[0:16] +
- md5(str(intMD5Total)).hexdigest()[0:16]
- )
- return ' '.join(arrEncryptedValues)
- # serial numbers
- strString = """99Z-KH5-OEM-240-1.1
- QGG-V33-OEM-0B1-1.1
- Z93-Z29-OEM-BNX-1.1
- IQ0-PZI-OEM-PK0-1.1
- UM4-VDL-OEM-B9O-1.1
- L0S-4R2-OEM-UQL-1.1
- JBL-EYQ-OEM-ABB-1.1
- NL1-3V3-OEM-L4C-1.1
- 7CQ-1ZR-OEM-U3I-1.1
- XX0-IHL-OEM-5XK-1.1
- KJQ-RXG-OEM-TW8-1.1
- OZR-LW1-OEM-5EM-1.1
- 0B8-6K5-OEM-EFN-1.1
- OE2-20L-OEM-SSI-1.1
- 0ME-HAE-OEM-9XB-1.1"""
- print encryptString(strString, "strPassword")
Results(partial answer print out for the sake of space):
Expand|Select|Wrap|Line Numbers
- -195 -208 -172 -218 -143 -99 -164 -230 -185 -150 -137 -196 -188 -134 -195 -223 -212 -235 -185 -251 -249 -202 -226 -127 -163 -154 -203 -167 -216 -170 -162 -149 -139 -124 -172 -149 -184 -156 -159 -167 -138 -211 -227 -173 -171 -217 -124 -142 -218 -166 -181 -142 -205 -173 -124 -166 -156 -223 -123 -161 -134 -202 -200 -182 -
Expand|Select|Wrap|Line Numbers
- 99Z-KH5-OEM-240-1.1
- QGG-V33-OEM-0B1-1.1
- Z93-Z29-OEM-BNX-1.1
- IQ0-PZI-OEM-PK0-1.1
- UM4-VDL-OEM-B9O-1.1
- L0S-4R2-OEM-UQL-1.1
- JBL-EYQ-OEM-ABB-1.1
- NL1-3V3-OEM-L4C-1.1
- 7CQ-1ZR-OEM-U3I-1.1
- XX0-IHL-OEM-5XK-1.1
- KJQ-RXG-OEM-TW8-1.1
- OZR-LW1-OEM-5EM-1.1
- 0B8-6K5-OEM-EFN-1.1
- OE2-20L-OEM-SSI-1.1
- 0ME-HAE-OEM-9XB-1.1"""