Results 1 to 27 of 27

Thread: [RESOLVED] Hashing Mysql example MySQL gives you. Like to know how its used

Threaded View

  1. #8

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2024
    Posts
    874

    Re: Hashing Mysql example MySQL gives you. Like to know how its used

    Quote Originally Posted by PlausiblyDamp View Post
    SHA2 is a hash function, that will return a hash of the string 'My secret passphrase', once that function has returned @key_str will contain the hash of the secret phrase. A hash is a one way trip, you cannot un-hash something to get the original data back.

    If you wanted to store a password (or pass phrase) you would take the hash of the password (often combined with a salt) and store the hash. That is all you would need to do. Hash the password and store the hash.


    The AES_ENCRYPT function is an encryption routine, it will generate an encrypted result that can later be decrypted back to the original data.

    The example from the documentation is taking a user supplied password, generating a hash from the password and then using the hash to encrypt the text, this resulting encrypted text could then be decrypted using the hash of the original password.

    If you want to store a password however, don't encrypt it - just hash it and store the hash.
    So, some of those set commands can be used as a password hash?

    mysql> SET @key_str = SHA2('My secret passphrase',512);

    @key_str is the hash of My secret passphrase?
    Interesting

    Have to think about this, like so then you would run that line on a user supplied password, and compare to the stored hash @key_str?
    If they match, user is authorized?
    Last edited by sdowney1; Jun 10th, 2024 at 07:42 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width