<div dir="ltr">I was following the tutorial the digital had. I am not a mysql expert so you could be right.</div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Mar 6, 2017 at 9:20 AM, Matt Graham <span dir="ltr"><<a href="mailto:mhgraham@crow202.org" target="_blank">mhgraham@crow202.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 2017-03-05 21:27, Herminio Hernandez, Jr. wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
UPDATE users SET<br>
password=ENCRYPT(%p,concat(_ut<wbr>f8'$1$',right(md5(rand()),8),_<wbr>utf8'$'))<br>
WHERE username=%u LIMIT 1<br>
<br>
This is using md5 for the hashing where as I am using SHA<br>
</blockquote>
<br></span>
To expand on this, the MySQL encrypt() function calls the system's crypt() function, which can be made to use a number of different hashes. A salt starting with $1$ is md5, $6$ is SHA512.<span class=""><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
INSERT INTO `servermail`.`virtual_users`<br>
(`id`, `domain_id`, `password` , `email`)<br>
VALUES<br>
('1', '1', ENCRYPT('firstpassword', CONCAT('$6$',<br>
SUBSTRING(SHA(RAND()), -16))), '<a href="mailto:email1@example.com" target="_blank">email1@example.com</a>'),<br>
I want to format this query correctly.<br>
</blockquote>
<br></span>
I think this isn't quite right, because the salt has to end with a $ according to the man page for crypt. I think you want CONCAT('$6$', SUBSTRING(SHA(RAND()), -16),'$')) but I could be wrong.<span class="HOEnZb"><font color="#888888"><br>
<br>
-- <br>
Crow202 Blog: <a href="http://crow202.org/wordpress" rel="noreferrer" target="_blank">http://crow202.org/wordpress</a><br>
There is no Darkness in Eternity<br>
But only Light too dim for us to see.<br>
------------------------------<wbr>---------------------<br>
PLUG-discuss mailing list - <a href="mailto:PLUG-discuss@lists.phxlinux.org" target="_blank">PLUG-discuss@lists.phxlinux.or<wbr>g</a><br>
To subscribe, unsubscribe, or to change your mail settings:<br>
<a href="http://lists.phxlinux.org/mailman/listinfo/plug-discuss" rel="noreferrer" target="_blank">http://lists.phxlinux.org/mail<wbr>man/listinfo/plug-discuss</a></font></span></blockquote></div><br></div>