Decryption SHA1 (1 Viewer)

lone_rider15

Registered User.
Local time
Today, 10:12
Joined
Nov 6, 2016
Messages
32
Hi,

I have a function for password hashing. I took the function from https://access-programmers.co.uk/forums/showthread.php?t=172530
Code:
Public Const Salt As Long = 543211234

Public Function Encrypt(strIn As String) As String
    Dim strChr As String
    Dim i As Integer
    
    For i = 1 To Len(strIn)
        strChr = strChr & CStr(Asc(Mid(strIn, i, 1)) Xor Salt)
    Next i
    Encrypt = strChr
End Function

It gives me "543211154543211139543211153543211153543211157543211149543211152543211142" for "Password".
Looking for solution: Decryption
How can I get "Password" for "543211154543211139543211153543211153543211157543211149543211152543211142"

Thanks in advance for looking into this.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 11:12
Joined
May 7, 2009
Messages
19,243
Sorry, no solution so far
 

nhorton79

Registered User.
Local time
Today, 15:12
Joined
Aug 17, 2015
Messages
147
Hi,



I have a function for password hashing. I took the function from https://access-programmers.co.uk/forums/showthread.php?t=172530

Code:
Public Const Salt As Long = 543211234



Public Function Encrypt(strIn As String) As String

    Dim strChr As String

    Dim i As Integer

    

    For i = 1 To Len(strIn)

        strChr = strChr & CStr(Asc(Mid(strIn, i, 1)) Xor Salt)

    Next i

    Encrypt = strChr

End Function



It gives me "543211154543211139543211153543211153543211157543211149543211152543211142" for "Password".

Looking for solution: Decryption

How can I get "Password" for "543211154543211139543211153543211153543211157543211149543211152543211142"



Thanks in advance for looking into this.



What are you trying to achieve with the decrypt?

If you're trying to check whether a password entered equals the stored encrypted password you're better not to decrypt.

Just check whether the password entered (encrypted) equals the stored encrypted password.

Something like:

IF encrypt(me.password) = dlookup("[password]","tblUsers","[userName] =" & me.username) THEN

'Code for correct password

ELSE

'Code for incorrect password

END IF

Or something to that effect. You might want to check my dlookup syntax to ensure I've typed that correctly.


Sent from my iPhone using Tapatalk
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Yesterday, 22:12
Joined
Feb 28, 2001
Messages
27,185
If I understand your function, it is easily reversible, but you have to think about what you are writing out in order to accomplish this reversal.

Going forward, you use

Code:
strChr = strChr & CStr(Asc(Mid(strIn, i, 1)) Xor Salt)

Your input is an 8 character string, a 9-digit Salt value, and you get as output something that appears to be about 72 characters long, which I would expect. It APPEARS to me that the formula you used would ALWAYS give you a digit string of length nine times the length of the input text string. Every 9-digit group in the output is the result of an XOR operation (which, fortunately for you, is a Hermetian operator - meaning "reversible").

To reverse this, you would do a similar loop but the key formula would be

Code:
strOut = strOut & Chr$( Val( Mid( strChr, ( ( i * 9 ) - 8 ), 9 ) Xor Salt ) )

It would look something like that, anyway. The idea is that you wrote out groups of 9 digits. Of those digits, at most three would have been affected by the Xor operator because the ASC function will return numbers in the range 0-255 at most (unless you are using UNICODE), so you would ALWAYS have one group of 9 digits per character of input. The reversal would thus be to slurp up 9 digits at a time of the long digit sequence, convert it back to a LONG, apply your Xor, and convert THAT back to a character using the Chr$ function.

For the record, if you have a true Hermetian operator (and XOR is one such operator) then

A XOR B = C and then C XOR B = A.

So if A is your input character, B is Salt, and C is a group of 9 digits, that is your key to reversal.
 

Users who are viewing this thread

Top Bottom