in reply to Re: Converting Java to Perl (MD5)
in thread Converting Java to Perl (MD5)

Thank you! definitely two programs both seem to output the same MD5 sum
-----------------------------------------------------------
Java
String plain = "abcd1234";
BigInteger digest = new BigInteger(1, md5.digest(plain.getB +ytes("UTF-8")));

Perl
my $plain = "abcd1234";
my $digest = Math::BigInt::->from_hex(md5_hex $plain);
-----------------------------------------------------------

But i want something different
-----------------------------------------------------------
Java
String plain = "abcd1234";
BigInteger digest = new BigInteger(md5.digest(plain.getB +ytes("UTF-8")));

Perl
my $plain = "abcd1234";
my $digest = Math::BigInt::->from_hex(md5_hex $plain);
-----------------------------------------------------------
its two programs output diffrent MD5 sum.. my $digest = Math::BigInt::->from_hex(md5_hex $plain); <--
 

Replies are listed 'Best First'.
Re^3: Converting Java to Perl (MD5)
by tobyink (Canon) on Feb 26, 2013 at 07:46 UTC

    The one argument form of the Java BigInteger constructor assumes you're passing in a binary two's complement integer.

    Math::BigInt doesn't have a two's complement constructor. You'd need to write one.

    package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name
      Oh, I get it. Thank you for your answer!