in reply to pack and AES help needed
Am I even close here? The example I got from the vendor shows a value like:
3e982f218e1872d269e53b980cc1a58d which is not what I'm getting.
#!/usr/bin/perl use Crypt::ECB; my $key = "1DC88FF231C6DB42A29F55EF1AB6D8DD"; $crypt = Crypt::ECB->new; $crypt->padding(PADDING_AUTO); $crypt->cipher('OpenSSL::AES') || die $crypt->errstring; $crypt->key($key); my $vers = 1; my $rand = rand(); my $time = time; my $empid = 912345678; my $packed = pack( "CLLL", $vers, $rand, $time, $empid ); my $sum = substr $packed, 0, 1; $sum ^= substr $packed, $_, 1 for 1 .. 7; $packed .= $sum; # encrypt the token my $token = $crypt->encrypt($packed); print "$token\n";
|
|---|