utf8 and md5.

I have old legacy code on .net 1.1 c#

Byte[] clearBytes = new
UnicodeEncoding().GetBytes(cleanString);
Byte[] hashedBytes = ((HashAlgorithm)
CryptoConfig.CreateFromName("MD5")).ComputeHash(clearBytes);

return BitConverter.ToString(hashedBytes);

how convert it into perl?
i trying this:
use utf8;
use Digest::MD5 qw ( md5 md5_hex md5_base64);
return uc(md5_hex(unpack("U*",$pass)))

but hash differs.

also trying unpack("H*"...


--
To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/
apm [ Do, 05 Mai 2011 17:53 ] [ ID #2059159 ]

Re: utf8 and md5.

On 05/05/2011 10:53 AM, apm wrote:
> I have old legacy code on .net 1.1 c#
>
> Byte[] clearBytes = new
> UnicodeEncoding().GetBytes(cleanString);
> Byte[] hashedBytes = ((HashAlgorithm)
> CryptoConfig.CreateFromName("MD5")).ComputeHash(clearBytes);
>
> return BitConverter.ToString(hashedBytes);
>
> how convert it into perl?
> i trying this:
> use utf8;
> use Digest::MD5 qw ( md5 md5_hex md5_base64);
> return uc(md5_hex(unpack("U*",$pass)))
>
> but hash differs.
>
> also trying unpack("H*"...
>
>

Did just md5_hex($pass) not work?

To help you diagnose this, some octet-streams of passwords and what your
C# program hashed them to would be helpful.

--
To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/
Lawrence Statton [ Do, 05 Mai 2011 17:59 ] [ ID #2059160 ]

Re: utf8 and md5.

just md5_hex( doesnt work.

For example, that c# code return
C3-1A-C6-05-79-3F-58-0B-38-6C-0F-B5-3F-1B-97-75
for string 12345




05.05.2011 21:59, Lawrence Statton :
> On 05/05/2011 10:53 AM, apm wrote:
>> I have old legacy code on .net 1.1 c#
>>
>> Byte[] clearBytes = new UnicodeEncoding().GetBytes(cleanString);
>> Byte[] hashedBytes = ((HashAlgorithm)
>> CryptoConfig.CreateFromName("MD5")).ComputeHash(clearBytes);
>>
>> return BitConverter.ToString(hashedBytes);
>>
>> how convert it into perl?
>> i trying this:
>> use utf8;
>> use Digest::MD5 qw ( md5 md5_hex md5_base64);
>> return uc(md5_hex(unpack("U*",$pass)))
>>
>> but hash differs.
>>
>> also trying unpack("H*"...
>>
>>
>
> Did just md5_hex($pass) not work?
>
> To help you diagnose this, some octet-streams of passwords and what your
> C# program hashed them to would be helpful.
>




--
To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/
apm [ Do, 05 Mai 2011 18:34 ] [ ID #2059163 ]

Re: utf8 and md5.

Le jeudi 05 mai 2011 =C3=A0 10:34:51, apm a =C3=A9crit :
> For example, that c# code return
> C3-1A-C6-05-79-3F-58-0B-38-6C-0F-B5-3F-1B-97-75
> for string 12345
With string 12345. I have try with md5sum and
md5_hex().
echo -n 12345 | md5sum
827ccb0eea8a706c4c34a16891f84e7b

I have the same result with md5_hex()

use strict;
use warnings;

use Digest::MD5 qw ( md5_hex );

print md5_hex("12345"), "\n";

I think that the function works well md5_hex. I do not know c #, so I do
not try, sorry.

--
\0/ Hobbestigrou
site web: http://erakis.im

--
To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/
hobbestigrou [ Do, 05 Mai 2011 23:29 ] [ ID #2059167 ]

Re: utf8 and md5.

Answer was:
my $bytes=3Dencode("utf16LE", $pass);
my $md5=3Duc(md5_hex($bytes));


06.05.2011 03:29, Natal Ng=C3=A9tal =D0=BF=D0=B8=D1=88=D0=B5=D1=82:
> Le jeudi 05 mai 2011 =C3=A0 10:34:51, apm a =C3=A9crit :
>> For example, that c# code return
>> C3-1A-C6-05-79-3F-58-0B-38-6C-0F-B5-3F-1B-97-75
>> for string 12345
> With string 12345. I have try with md5sum and
> md5_hex().
> echo -n 12345 | md5sum
> 827ccb0eea8a706c4c34a16891f84e7b
>
> I have the same result with md5_hex()
>
> use strict;
> use warnings;
>
> use Digest::MD5 qw ( md5_hex );
>
> print md5_hex("12345"), "\n";
>
> I think that the function works well md5_hex. I do not know c #, so I d=
o
> not try, sorry.
>



--
To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/
apm [ Fr, 06 Mai 2011 07:16 ] [ ID #2059227 ]
Perl » gmane.comp.lang.perl.beginners » utf8 and md5.

Vorheriges Thema: special character regex match
Nächstes Thema: [OFF] OSS Perl Shopping Carts