ghamrick has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks, my predecessor created an encryption routine in perl with the following construct as a key:
pack "a16", 0x1d, 0x29, 0xda, 0xe8, 0xa5, 0x98, 0x3c, 0x91, 0x33, 0x1d, 0xae, 0x55, 0x2f, 0xf6, 0x85, 0xec;
I need to use this same key in java to decrypt some of these items, and cannot figure out how to create this structure in java. I realize that this is not strictly a perl question, so please forgive if I have wandered off the path. Thank you.

Replies are listed 'Best First'.
Re: pack construct in java
by tobyink (Canon) on Mar 12, 2013 at 16:47 UTC

    It's equivalent to the following string in Java

    "29\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\ +u0000\u0000\u0000"

    For what it's worth, they probably meant one of:

    pack "a"x16, ...; pack "c"x16, ...;

    ... which would have made more sense. In the version you posted, only the first hex number is used (0x1d == 29) and padded to 16 bytes; the rest are ignored.

    package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name