#!/usr/local/bin/perl #---------------------------------- # パスワード暗号ユーティリティ # for UNIX/perl4,5 # (c)www.rescue.ne.jp #---------------------------------- $buffer = $ENV{'QUERY_STRING'}; @pairs = split(/&/,$buffer); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $FORM{$name} = $value; } if ($buffer eq '') { print "Content-type: text/html\n\n"; print "
\n"; print "
\n"; print "\n"; exit; } if ($FORM{'plain'} eq '' || length($FORM{'plain'}) < 6) { &error('6文字以上のパスワードを入力してください.'); } sub crypt { my $mypass = $_[0]; srand(); my @saltset = ('a'..'z','A'..'Z','0'..'9','.','/'); my $nsalt = $saltset[int(rand(64))] . $saltset[int(rand(64))]; return crypt($mypass,"$nsalt"); } $result = &crypt($FORM{'plain'},$nsalt); if ($result =~ /^\$1\$/) { $salt = 3; } else { $salt = 0; } if (crypt($FORM{'plain'}, substr($result,$salt,2)) eq $result) { $verify = 'OK'; } else { $verify = 'NG'; } print "Content-type: text/html\n\n"; print "
\n"; print "\n"; print "\n"; exit; sub error { print "Content-type: text/html\n\n"; print "