I have a calculated variable $otp which is decrypted using AES key $key.
 If the variable was properly decrypted, the first six bytes of the
decrypted data should match what is in $userid, I think.

How do I extract the first six bytes of $plaintext and compare it to
what's in $userid ?

Regards,
Lars


#!/usr/bin/perl

use strict;
use warnings;
use Convert::ModHex qw(modhex2hex);
use Crypt::Rijndael;

my $input  = qq(ujvrgjnigiibvrjctcflercebvcvhicbnhhheliclnfh);
my $key    = qq(83b396b8f996fa1be3dafdc3f0eefc21);
my $userid = qq(aa6d0a6e8a65);

my ( $publicid, $otp ) = ( $input =~ /^(.*)(.{32})$/ ); # OTP 32B

my $hex = modhex2hex($otp);
print qq(publicid=$publicid\n$otp\n$hex\n\n);

my $cipher = Crypt::Rijndael->new( $key, Crypt::Rijndael::MODE_CBC() );

my $plaintext = $cipher->decrypt($hex);

print qq(\np=$plaintext\n);

exit( 0 );

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to