-
-
Save ab5tract/20c489d20f289af31533 to your computer and use it in GitHub Desktop.
sha1 hash
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
subset Sha1 of Str where *.chars == 40 and m:i/<[A..Z 0..9]>/; | |
class Sha1H does Associative { | |
has $!sha1; | |
has %!h{Sha1(Str)}; | |
method AT-KEY($_) { %!h{ .lc } }; | |
method ASSIGN-KEY($_, $v) { %!h{ .lc } = $v } | |
} | |
class Sha1Str is Str { | |
method Sha1 { | |
(('a'..'z').pick(10) X (^10).pick(10)).roll(20).flat.join; | |
} | |
} | |
my %h is Sha1H; | |
my $sha1 = Sha1Str.new; # '64B0F6C3681E428CCE2EB830B05F27B3D7ED643'; | |
say $sha1.Sha1; | |
%h{$sha1} = 'a'; | |
say %h{$sha1}; | |
%h<a> = 'b'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment