0

Is mysql5 algoritm is SHA-1(SHA-1($pass)) ?

Then i trying this http://vb.wikia.com/wiki/SHA-1.bas script, with function =SHA1HASH(SHA1HASH("test")) i get c4033bff94b567a190e33faa551f411caef444f2 but Mysql5 hash must be 94BDCEBE19083CE2A1F959FD02F964C7AF4CFC29

How to convert string to Mysql5 hash in VBA?

enter image description here

I have found why this hapens,

because Sha1 provided in Hex, but Mysql5 in binary

sd vb
  • 13
  • 4
  • Are you sure $pass = "test"? SELECT SHA1(SHA1('test')) = c4033bff94b567a190e33faa551f411caef444f2 – Eldarni Feb 23 '13 at 10:06
  • Yes i am sure http://i.stack.imgur.com/rnpfI.png – sd vb Feb 23 '13 at 10:18
  • what did you use to calculate the following hash: 94BDCEBE19083CE2A1F959FD02F964C7AF4CFC29 – Eldarni Feb 23 '13 at 10:19
  • To generate the hash provided, try in mysql `SELECT PASSWORD("test")`, If you need to use the password hashing outside of mysql - I would recommend that you use sha1 - with salting. http://dev.mysql.com/doc/refman/5.0/en/encryption-functions.html#function_password – Eldarni Feb 23 '13 at 10:24
  • I need Excel VBA. I use http://www.insidepro.com/hashes.php?lang=eng to calculate the following hash: 94BDCEBE19083CE2A1F959FD02F964C7AF4CFC29 – sd vb Feb 23 '13 at 10:25
  • In that case you will need to locate the hashing algorithm use by MySQL in the PASSWORD function and reverse engineer a solution to use in VBA - as the PASSWORD function does not use a unsalted SHA1 or MD5 hashing method. – Eldarni Feb 23 '13 at 10:32

1 Answers1

1

It looks like the string 94BDCEBE19083CE2A1F959FD02F964C7AF4CFC29 was generated via the MySQL function PASSWORD().

SELECT PASSWORD("test") /* *94BDCEBE19083CE2A1F959FD02F964C7AF4CFC29 */

As recommended by the MySQL documentation if you need to maintain all you hash code in excel you need to change your original hashing process to use something like SHA1.

From the MySQL documentation: http://dev.mysql.com/doc/refman/5.0/en/encryption-functions.html#function_password The PASSWORD() function is used by the authentication system in MySQL Server; you should not use it in your own applications. For that purpose, consider MD5() or SHA1() instead.

Eldarni
  • 425
  • 1
  • 3
  • 9
  • I do not want change anything, i want get *94BDCEBE19083CE2A1F959FD02F964C7AF4CFC29 from string test in EXCEL VBA – sd vb Feb 23 '13 at 10:41
  • 1
    Why do you want to get that particular hash - it is a proprietary hashing method used by MySQL 5 to generate internal hashes for MySQL. There own documentation recommends that you do not use it. Unless you have already gone down a irreversible route I highly recommend you switch to a non-proprietary option. If you NEED to use the MySQL PASSWORD() function, you will need to install connect to either a local or remote MySQL server from your VBA module, run the following SQL `SELECT PASSWORD("test")` and get the result. – Eldarni Feb 23 '13 at 10:54
  • i have already generated passwords in Mysql5 hashes from passwords, i just want to compare if password has been changed – sd vb Feb 23 '13 at 11:01