Hi :) I am also a hobbyist, and I think I can point you in the right direction, despite the fact that I do not know how magic happens. 1) the user enters his password, the program encrypts using a specific method, and this secret password is saved. 2) bam. NOBODY can see what the original is - even the user who entered it. When entering the system, this operation is repeated, and the password “any user enters to enter” is encrypted with the same process, and then compared with the encrypted saved password. They must match if they were the same unencrypted original.
Well
For added security, something called a “salt” is sometimes added to the encryption process, making it even harder to crack a password. Tell me, did someone somehow grab your encryption code and the encrypted password list and try to get the process back by reverse engineering your code? Well, now this person has additional work to find out what your “salt” was ... (it could be a string stored on your server, a smart game “with dates of the month”, etc. .... many options ), This is what I remember from what I read. Lots of pointers to get you started. And further:
I use this: what I got from somewhere on the Internet a few years ago
function encryptTheString($password, $salt, $iter_count=4096, $keylen=64, $hash_alg= 'sha256' ) { // Compute the length of hash alg output. // Some folks use a static variable and save the value of the hash len. // Considering we are doing 1000s hmacs, doing one more won't hurt. $hashlen = strlen(hash($hash_alg, null, true)); // compute number of blocks need to make $keylen number of bytes $numblocks = ceil($keylen / $hashlen); // blocks are appended to this $output = ''; for ($i = 1; $i <= $numblocks; ++$i) { $block = hash_hmac($hash_alg, $salt . pack('N', $i), $password, true); $ib = $block; for ($j = 1; $j < $iter_count; ++$j) { $block = hash_hmac($hash_alg, $block, $password, true); $ib ^= $block; } $output .= $ib; } // extract the right number of output bytes return substr($output, 0, $keylen); }
And a call like
$ePassword=ANDYETpbkdf2($password,"111111111122222222223333333333444444444455555555566666666661234");
It would be perfectly fine: give sha256 a reading to begin further enlightenment.