Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
49 additions
and
5 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
use v6; | ||
|
||
use Digest; | ||
|
||
if ( @*ARGS.elems != 2 ) { | ||
say 'This program expects two arguments, the first one should be the'; | ||
say 'username of the new user and the second one should be the passphrase'; | ||
say 'of the new user.'; | ||
say "\nThank You"; | ||
exit 1; | ||
} | ||
|
||
my ($username, $passphrase) = @*ARGS; | ||
|
||
say "The hashed passphrase for $username is:"; | ||
say " ", digest( digest( $username, 'sha256' ) ~ $passphrase, 'sha256'); | ||
|
||
# vim: ft=perl6 |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
|
||
use Test; | ||
use Digest; | ||
|
||
plan 6; | ||
|
||
my $text = "The quick brown fox jumps over the lazy dog"; | ||
|
||
ok(Digest::digest($text) | ||
eq "9e107d9d372bb6826bd81d3542a419d6", | ||
'Default is MD5'); | ||
ok(Digest::digest($text, "md5") | ||
eq "9e107d9d372bb6826bd81d3542a419d6", | ||
'MD5 is correct'); | ||
ok(Digest::digest($text, "sha1") | ||
eq "2fd4e1c67a2d28fced849ee1bb76e7391b93eb12", | ||
'SHA1 is correct'); | ||
ok(Digest::digest($text, "sha256") | ||
eq "d7a8fbb307d7809469ca9abcb0082e4f8d5651e46d3cdb762d02d0bf37c9e592", | ||
'SHA256 is correct'); | ||
ok(Digest::digest($text, "sha512") | ||
eq "07e547d9586f6a73f73fbac0435ed76951218fb7d0c8d788a309d785436bbb642e93a252a954f23912547d1e8a3b5ed6e1bfd7097821233fa0538f3db854fee6", | ||
'SHA512 is correct'); | ||
ok(Digest::digest($text, "ripemd160") | ||
eq "37f332f68db77bd9d7edd4969571ad671cf9dd3b", | ||
'ripemd160 is correct'); |