473,396 Members | 1,945 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Reversing an algorithm

Thekid
145 100+
Hi,
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
  1. from hashlib import md5
  2. evalCrossTotal = lambda strMD5: sum(map(lambda x: int(x, 16), strMD5))
  3. def encryptString(strString, strPassword):
  4.     # strString is the content of the entire file with serials
  5.     strPasswordMD5 = md5(strPassword).hexdigest()
  6.     intMD5Total = evalCrossTotal(strPasswordMD5)
  7.     arrEncryptedValues = []
  8.     for i in range(len(strString)):
  9.         arrEncryptedValues.append(
  10.             str(ord(strString[i]) + int(strPasswordMD5[i%32], 16) - intMD5Total)
  11.         )
  12.         intMD5Total = evalCrossTotal(
  13.             md5(strString[0:i+1]).hexdigest()[0:16] +
  14.             md5(str(intMD5Total)).hexdigest()[0:16]
  15.         )
  16.     return ' '.join(arrEncryptedValues)
  17. # serial numbers
  18. strString = """99Z-KH5-OEM-240-1.1
  19.    QGG-V33-OEM-0B1-1.1
  20.    Z93-Z29-OEM-BNX-1.1
  21.    IQ0-PZI-OEM-PK0-1.1
  22.    UM4-VDL-OEM-B9O-1.1
  23.    L0S-4R2-OEM-UQL-1.1
  24.    JBL-EYQ-OEM-ABB-1.1
  25.    NL1-3V3-OEM-L4C-1.1
  26.    7CQ-1ZR-OEM-U3I-1.1
  27.    XX0-IHL-OEM-5XK-1.1
  28.    KJQ-RXG-OEM-TW8-1.1
  29.    OZR-LW1-OEM-5EM-1.1
  30.    0B8-6K5-OEM-EFN-1.1
  31.    OE2-20L-OEM-SSI-1.1
  32.    0ME-HAE-OEM-9XB-1.1"""
  33. print encryptString(strString, "strPassword")
  34.  
  35.  

Results(partial answer print out for the sake of space):
Expand|Select|Wrap|Line Numbers
  1. -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 -
  2.  
Instead, I would need to take numbers in the above format and have them print out in this format:
Expand|Select|Wrap|Line Numbers
  1.    99Z-KH5-OEM-240-1.1
  2.    QGG-V33-OEM-0B1-1.1
  3.    Z93-Z29-OEM-BNX-1.1
  4.    IQ0-PZI-OEM-PK0-1.1
  5.    UM4-VDL-OEM-B9O-1.1
  6.    L0S-4R2-OEM-UQL-1.1
  7.    JBL-EYQ-OEM-ABB-1.1
  8.    NL1-3V3-OEM-L4C-1.1
  9.    7CQ-1ZR-OEM-U3I-1.1
  10.    XX0-IHL-OEM-5XK-1.1
  11.    KJQ-RXG-OEM-TW8-1.1
  12.    OZR-LW1-OEM-5EM-1.1
  13.    0B8-6K5-OEM-EFN-1.1
  14.    OE2-20L-OEM-SSI-1.1
  15.    0ME-HAE-OEM-9XB-1.1"""
  16.  
Any suggestions?
Sep 18 '08 #1
4 1663
Smygis
126 100+
I love you're excessive use of comments.

Yeah its super simple. md5 is a one way hash. You cant reverse it.
Sep 18 '08 #2
Thekid
145 100+
I love you're excessive use of comments.

Yeah its super simple. md5 is a one way hash. You cant reverse it.
I'll be sure and give that as my answer. If you don't understand what I'm asking, please check with me and I will clarify it.
Sep 18 '08 #3
pbmods
5,821 Expert 4TB
Heya, TheKid.

Care to tell us why you want to crack this encryption algorithm?
Sep 19 '08 #4
RedSon
5,000 Expert 4TB
Is this question about how to make the ouput change? Or is it an encryption question?
Sep 19 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Kevin | last post by:
Hello, I need to some help in reversing an 2-dimensional array. I am working with gif images and I am trying to make the mirror image. I was hoping that someone could help give me a headstart...
11
by: Tim Marshall | last post by:
I use Terry Kreft's & Stephen Lebans colour dialog procedures for users to pick colours for various control properties in certain apps. Is there a way to take the colour code that is displayed in...
45
by: Ajay | last post by:
Hi all,can you please tell the most efficient method to reverse a byte.Function should return a byte that is reversed.
6
by: neo | last post by:
Hello everyone, I want to write a function that takes a simple text file as input and outputs a file such that the last line in the input file becomes the first line in the output file and the...
3
by: dru | last post by:
Problem: Reversing the elements of an array involves swapping the corresponding elements of the array: the first with the last, the second with the next to the last, and so on, all the way to the...
4
by: hello12 | last post by:
Hello, I am new to java and i was having a hard time figuring out on how to do certain string manipulations. I was asked to read in a text file and reverse the words. So far, I have put all...
8
by: arnuld | last post by:
i have created a solutions myself. it compiles without any trouble and runs but it prints some strange characters. i am not able to find where is the trouble. ...
4
by: saki | last post by:
How do we reverse a singly linked list without using extra memory.Extra pointers can however be used
3
Thekid
by: Thekid | last post by:
Is it difficult to reverse an algorithm in php? There is an example of what the encrypted text looks like below it and an example of how it should print out. Or could I get some kind of explanation...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.