Created
January 31, 2014 08:26
-
-
Save fand/8728397 to your computer and use it in GitHub Desktop.
Digest::MD5 hex digest ???
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
use utf8; | |
use Encode; | |
use Digest::MD5; | |
use v5.010; | |
my $str = 'ジムに行き筋肉ムキムキ'; | |
# OOP style | |
my $ctx = Digest::MD5->new; | |
$ctx->add(encode_utf8 $str); | |
say 'OOP : ' . $ctx->hexdigest; | |
# => OOP : ad9049eb074cfb67c84cf444097fdf7d | |
# Functional style | |
say 'Func: ' . Digest::MD5->md5_hex(encode_utf8 $str); | |
# => Func: ee8b1a5de3a63dd3dfe50488088af2bb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
use utf8; | |
use Digest::MD5; | |
use v5.010; | |
my $data = pack('i3', 1, 2, 3); | |
# OOP style | |
my $ctx = Digest::MD5->new; | |
$ctx->add($data); | |
say 'OOP style : ' . $ctx->hexdigest; | |
# => OOP : 2a1dd1e1e59d0a384c26951e316cd7e6 | |
# Functional style | |
say 'Func style: ' . Digest::MD5->md5_hex($data); | |
# => Func: f258168ffea40d1bf16a631eb87b07f4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment