What encryption is this?

For everything that's not in any way related to PureBasic. General chat etc...
User avatar
GeoTrail
Addict
Addict
Posts: 2794
Joined: Fri Feb 13, 2004 12:45 am
Location: Bergen, Norway
Contact:

What encryption is this?

Post by GeoTrail »

I have this hash or whatever it is
70617373776f7264
I'm trying to find out how it is encrypted, or which hash it is. I know the unencrypted text is password.

Any takers?
I Stepped On A Cornflake!!! Now I'm A Cereal Killer!
MrMat
Enthusiast
Enthusiast
Posts: 762
Joined: Sun Sep 05, 2004 6:27 am
Location: England

Post by MrMat »

It looks like the ascii values of each letter in "password", written in hex. So $70 = 112 = 'p', $61 = 97 = 'a', etc.
Mat
User avatar
GeoTrail
Addict
Addict
Posts: 2794
Joined: Fri Feb 13, 2004 12:45 am
Location: Bergen, Norway
Contact:

Post by GeoTrail »

Like this?
Hex(Asc("p"))

Think that is right, but how do I reverse it? How do I unencode it?
I Stepped On A Cornflake!!! Now I'm A Cereal Killer!
MrMat
Enthusiast
Enthusiast
Posts: 762
Joined: Sun Sep 05, 2004 6:27 am
Location: England

Post by MrMat »

Yes that's it. So this displays the hex string above:

Code: Select all

str.s = "password"
text.s = ""
For l = 0 To Len(str) - 1
text + Hex(PeekB(@str + l))
Next
Debug(text)
Mat
User avatar
GeoTrail
Addict
Addict
Posts: 2794
Joined: Fri Feb 13, 2004 12:45 am
Location: Bergen, Norway
Contact:

Post by GeoTrail »

That is very helpfull MrMat. How can I unencrypt a hex string created in that manner?
I Stepped On A Cornflake!!! Now I'm A Cereal Killer!
MrMat
Enthusiast
Enthusiast
Posts: 762
Joined: Sun Sep 05, 2004 6:27 am
Location: England

Post by MrMat »

It's not really encrypted so you can just PeekS it: Debug(PeekS(@str)) if it's null-terminated or Debug(PeekS(@str, length)) if you know it's length.
Mat
MrMat
Enthusiast
Enthusiast
Posts: 762
Joined: Sun Sep 05, 2004 6:27 am
Location: England

Post by MrMat »

That's if it is already in memory. If you are given it as a string then:

Code: Select all

Procedure.l Convert(a.s)
    ProcedureReturn FindString("0123456789abcdef", LCase(a), 1) - 1
EndProcedure

str.s = "70617373776f7264"
text.s = ""
For l = 1 To Len(str) Step 2
val.l = Convert(Mid(str, l, 1)) << 4 + Convert(Mid(str, l + 1, 1))
text + Chr(val)
Next
Debug(text)
Mat
User avatar
GeoTrail
Addict
Addict
Posts: 2794
Joined: Fri Feb 13, 2004 12:45 am
Location: Bergen, Norway
Contact:

Post by GeoTrail »

Perfect MrMat, thanks alot for your assistance.
Oh, and good morning :D
I Stepped On A Cornflake!!! Now I'm A Cereal Killer!
MrMat
Enthusiast
Enthusiast
Posts: 762
Joined: Sun Sep 05, 2004 6:27 am
Location: England

Post by MrMat »

Glad to help and good morning to you :D
Mat
Post Reply