package encryptstuffmodule; use Exporter; use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); use Crypt::Blowfish; $VERSION = 1.00; @ISA = qw(Exporter); @EXPORT = (); @EXPORT_OK = qw(&encryptforauthorize &encryptnew); %EXPORT_TAGS = (DEFAULT => [qw(&encryptforauthorize)], AddNewEncrypt => [qw(&encryptnew)]); sub encryptnew { my $encryptme = sprintf("%08d", $_[0]); my $fileforpass = "/foo/bar/baz/.passwords"; #a database is proably better but I will use a file for example my $salt = pack("H16", "hf73mkf6vbf559"); my $encrypted = $cipher->encrypt($encryptme); open (TESTFILE, ">>$fileforpass") || die "TESTFILE cannot open"; print TESTFILE $encrypted, "\n"; return 1; } sub encryptforauthorize { my $fileforpass = "/foo/bar/baz/.passwords"; my $salt = pack("H16", "hf73mkf6vbf559"); my $cipher = new Crypt::Blowfish $salt; my $forcompare = $cipher->encrypt(sprintf("%08s", $_[0])); open (TESTFILE, $fileforpass) || die "File cannot open"; while () { chomp; return "okay" if $forcompare eq $_; } return "bad"; } 1;