in reply to Re: Storing encrypted passwords and validating
in thread Storing encrypted passwords and validating
sub get_digest { my ($passwd) = @_; my $salt = gen_8_rand_bytes()); my $digest = Digest::SHA1::sha1_hex("$salt$passwd"); return unpack('H16', $salt) . $digest; } sub cmp_digest { my ($passwd, $digest) = @_; my $salt = pack('H16', substr($digest, 0, 16, '')); return $digest eq Digest::SHA1::sha1_hex("$salt$passwd"); }
There's probably an existing implementation on CPAN that follows established practices.
|
|---|