Reproduce users password externally

Hi to all!

I’m tryng to reproduce the “suitecrm.users.user_hash” column creation outside SuiteCRM.

I try this code, bt the hash not match with the db record.
Where I’m wrong?


<?php
$salt = substr("myusername", 0, 2);
$user_password = "mypassword";
$encrypted_password = crypt($user_password, $salt);
echo $encrypted_password;
?>

ups,
the crypt PHP function generate randomly a different hash.
but the function basically can be correct adding the md5 encrypt:


<?php
$user_password = md5("mypassword");
$encrypted_password = crypt($user_password);
echo $encrypted_password;
?>