Submit Your Article Forum Rules

Results 1 to 7 of 7

Thread: MySQL - SHA1 Encryption

  1. #1
    WebProWorld MVP Clicken's Avatar
    Join Date
    Jul 2004
    Posts
    327

    MySQL - SHA1 Encryption

    When CREATING a table column using MyPHPAdmin there isn't a choice in the selection for SHA1, however when browsing the existing table entries, if I choose to edit a row then the option is there for SHA1, go figure.

    I have found how to UPDATE my table password column to SHA1 but that will only effect the current rows.

    MySQL column specs don't support function calls so; How can I get the password column to use SHA1 on newly added rows?

  2. #2
    WebProWorld MVP DaveSawers's Avatar
    Join Date
    Dec 2006
    Location
    Lunenburg, Nova Scotia, Canada
    Posts
    762
    SHA1 isn't a variable type, it's an encryption method that returns an encrypted string that you can save on your database as a binary(n) field. You then retrieve the value and decrypt it before using it.
    Dynamic Software Development
    www.activeminds.ca

  3. #3
    WebProWorld MVP Clicken's Avatar
    Join Date
    Jul 2004
    Posts
    327
    Thanks Dave.

    After sitting up half the night studying the problem, that is what I was thinking, but not in those words exactly!

    I need to post in the programming forum for help on how to save the password as an encryption.

  4. #4
    Senior Member
    Join Date
    Nov 2003
    Posts
    135
    Part of your problem might be how you are asking the question. SHA-1 is not an encryption algorithm; instead it's a hash. Hashes are not "decryptable" but they are very good for storing peoples passwords for authentication purposes -- unless you need the value to use to authenticate to another system. Sorry I can't answer your question; my knowledge of mySQL is minimal (I've used it barely).
    --Steve (blog)
    www.shift4.com -- Secure payment processing

  5. #5
    WebProWorld MVP DaveSawers's Avatar
    Join Date
    Dec 2006
    Location
    Lunenburg, Nova Scotia, Canada
    Posts
    762
    Quote Originally Posted by Shift4SMS View Post
    SHA-1 is not an encryption algorithm; instead it's a hash.
    SHA is an acronym for Secure Hash Algorithm
    Dynamic Software Development
    www.activeminds.ca

  6. #6
    WebProWorld MVP Clicken's Avatar
    Join Date
    Jul 2004
    Posts
    327
    Just so we know; If SHA1 is a Secure HASH Algorithm is that different from an ENCRYPTION algorithm? Yii calls it encryption().

    And,... i searched through many examples for getting the sha1 passed to the db before finding one that was applicable for my situation. Yeah, problem solved!

    I found that the PHP can set the new table row for it upon creation. So actually the hash would be created on the db end, but I didn't like that method, it seems a bit unecesary since the framework already has methods for passing the hash.

  7. #7
    Senior Member
    Join Date
    Nov 2003
    Posts
    135
    Quote Originally Posted by Clicken View Post
    Just so we know; If SHA1 is a Secure HASH Algorithm is that different from an ENCRYPTION algorithm? Yii calls it encryption().
    Encryption implies decrypt able data. Hashes are not decrypt able.

    Think of a hash as the sum of your data: 1+8+3+7+1+5+3+2=30, 30 would be the hash. With just 30, it's impossible to know the numbers used to create the value -- hence not decrypt able.
    Last edited by Shift4SMS; 12-21-2011 at 12:56 PM.
    --Steve (blog)
    www.shift4.com -- Secure payment processing

Posting Permissions

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