crypt関数を使用することを考えて、別の比較的大きな文字列(ディレクトリパス名で構成される)を指定して、一意の文字列/ IDを生成しようとしています。しかし、おそらく私の理解力の欠如が原因で、期待どおりに機能していません。
ここにコードと出力:
#!/usr/bin/perl
print "Enter a string:";
chomp(my $string = <STDIN>);
my $encrypted_string = crypt($string,'di');
print "\n the encrypted string is:$encrypted_string";
出力:
$ perl crypt_test
Enter a string:abcdefghi
the encrypted string is:dipcn0ADeg0Jc
$
$ perl crypt_test
Enter a string:abcdefgh
the encrypted string is:dipcn0ADeg0Jc
$
$
$ perl crypt_test
Enter a string:abcde
the encrypted string is:diGyhSp4Yvj4M
$
最初の 2 つの文字列では同じ暗号化文字列を返し、3 番目の文字列では異なる理由がわかりませんでした。塩はすべて同じであることに注意してください。