Hashing an entire column with sha512

I have a table with three columns with the name: Question, Answer, Hashed. I want to update the hashed column with the hashed column with sha512.

I tried updating directly from the MySql database using this syntax, but this did not work:

UPDATE TableName SET Hashed = SHA512 (Answer) WHERE hashed IS NULL

I know the syntax is incorrect, but not sure why.

Thanks in advance for your help!

R

+4
source share
2 answers

Take a picture.

UPDATE TableName SET Hashed=SHA2(Answer, 512) WHERE Hashed IS NULL; 

Please note that this will only work with MySQL 5.5. For versions prior to 5.5, you will need to use the application code for the hash (PHP to get all the lines, repeat and hash $ row ['reply'] in SHA512, and then run the UPDATE commands for each) (Source: http: //dev.mysql .com / doc / refman / 5.5 / en // encryption-functions.html # function_sha2 )

+10
source

Hope it's not too late. Even if, maybe, someone else recognizes this hint:

 UPDATE TableName SET Hashed = ENCRYPT('Answer', CONCAT('$6$', SUBSTRING(SHA(RAND()), -16))) WHERE Hashed IS NULL; 

What he does, he creates a hash file sha-512, with it the scheme: $6$ from the line "Answer"

If you use debian, you can also use mkpasswd from the libstring-mkpasswd-perl package to generate SHA-512 for you and update as a string.

0
source

Source: https://habr.com/ru/post/1436493/


All Articles