perl & php: perl equivalent of php md5 function

Trabla: perl & php: perl equivalent of php md5 function




perl equivalent of php md5 function tutorial
Solving:

1. PHP code:

<?php

$password = "trololo";

echo md5($password);

?>

Result:  37f62f1363b04df4370753037853fe88

perl equivalent of php md5 function tutorial screenshot

2.  PERL code:

 # Functional style
 use Digest::MD5 qw(md5_hex);

 $password = 'trololo';

 $digest = md5_hex($password);

 print $digest . "\n";

 Result: 37f62f1363b04df4370753037853fe88


 # Object-oriented  style
 use Digest::MD5;

 $password = 'trololo';

 $md5 = Digest::MD5->new;

 $md5->add( $password );
 $digest = $md5->hexdigest;

 print $digest . "\n";

 

 Result: 37f62f1363b04df4370753037853fe88

No comments:

Post a Comment