一段生成linux passwd的perl脚本

来源:互联网 发布:黑暗之魂世界观知乎 编辑:程序博客网 时间:2024/05/16 16:04
脚本如下,最终是用crypttext来加密。不懂的是中间这句,my$plaintext=shift;
有了解的讲解一下。
#!/usr/bin/perl
srand (time());
my $randletter = "(int (rand (26)) + (int (rand (1) + .5) % 2 ? 65 : 97))";
my $salt = sprintf ("%c%c", eval $randletter, eval $randletter);
my $plaintext = shift;
my $crypttext = crypt ($plaintext, $salt);
print "${crypttext}/n";