是Perl CGI的新手,使用ActivePerl,SQLite DB,Apache服务器和Windows.我有一个输入表单,其中包括Id,Name,Password等字段.每当有人创建新条目时,无论他们进入密码字段,应加密并存储在数据库中.
下一次当同一个用户输入密码时,应该验证它.现在我想要一个解密函数或代码.
我发现了一种叫做MD5加密的东西.请任何人可以给我更多关于此的信息,并帮助我如何编写代码或任何相关的链接?
dax*_*xim 10
make_crypto_hash最初设置用户时调用,参数是他给定的密码.将函数返回值存储在数据库中.
sub make_crypto_hash {
my ($passphrase) = @_;
return Authen::Passphrase::BlowfishCrypt->new(
cost => 8,
salt_random => 1,
passphrase => $passphrase,
)->as_rfc2307;
}
Run Code Online (Sandbox Code Playgroud)
match_passphrase_against_crypto_hash当有人登录并且您想要查看密码是否属于该用户时呼叫.参数是您从数据库中检索给定用户名的加密哈希值,以及用户刚刚给出的密码短语.返回值是布尔值.
sub match_passphrase_against_crypto_hash {
my ($crypto_hash, $passphrase) = @_;
return Authen::Passphrase::BlowfishCrypt
->from_rfc2307($crypto_hash)->match($passphrase);
}
Run Code Online (Sandbox Code Playgroud)