On 06/02/2015 01:18 PM, Shlomi Fish wrote: > Hi Lars, > > please reply to all recipients. > > On Tue, 02 Jun 2015 12:54:54 +0300 > Lars Noodén <lars.noo...@gmail.com> wrote: > >> 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 ? >> > > To extract the first six bytes, use the substr function: > > http://perldoc.perl.org/functions/substr.html > > The command «my $first_6_bytes = substr($plaintext, 0, 6);» ought to do the > tricks (but there may be some complications due to Unicode and > charsets/encoding). > > To compare it to $userid, you can use "eq", "cmp", etc. See: > > http://perldoc.perl.org/perlop.html > > It seems that $userid is encoded in hex so you'll need to convert it to a > plain > binary string first. > > Regards, > > Shlomi Fish
Hi, Shlomi, Thanks. Is there a convenient way to convert the binary string to hex instead? Regards, Lars -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/