Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Update code so that it runs on current rakudo

  • Loading branch information...
commit 20797e0b8cc7a846aad85a66022a85e2ea6ed85a 1 parent c455e05
Carlin authored
Showing with 23 additions and 10 deletions.
  1. +23 −10 lib/Digest/SHA256.pm
View
33 lib/Digest/SHA256.pm
@@ -2,7 +2,7 @@
module Digest::SHA256:<soh-cah-toa 0.1>;
-=begin
+=begin Pod
=head1 NAME
@@ -60,23 +60,36 @@ This program is distributed under the terms of the Artistic License 2.0.
For further information, please see LICENSE or visit
<http://www.perlfoundation.org/attachment/legal/artistic-2_0.txt>.
-=end
+=end Pod
=cut
pir::load_bytecode('Digest/sha256.pir');
-my $sum = Q:PIR { %r = get_root_global ['parrot'; 'Digest'], '_sha256sum' };
-my $hex = Q:PIR { %r = get_root_global ['parrot'; 'Digest'], '_sha256_hex' };
-my $print = Q:PIR { %r = get_root_global ['parrot'; 'Digest'], '_sha256_print' };
+my $PD := Q:PIR { %r = new ['Digest';'SHA256'] };
-multi sub sha256_sum(Str $msg) is export { return $sum.($msg) }
-multi sub sha256_sum(@msg) is export { return sha256_sum(@msg.join) }
+multi sub sha256_sum(Str $msg) is export {
+ return nqp::p6box_s($PD.sha_sum($msg));
+}
-multi sub sha256_hex(Str $msg) is export { return $hex.($sum.($msg)) }
-multi sub sha256_hex(@msg) is export { return sha256_hex(@msg.join) }
+multi sub sha256_sum(@msg) is export {
+ return nqp::p6box_s($PD.sha_sum(@msg.join));
+}
- sub sha256_print(@sum) is export { $print.(@sum) }
+multi sub sha256_hex(Str $msg) is export {
+ sha256_sum($msg);
+ return nqp::p6box_s($PD.sha_hex());
+}
+
+multi sub sha256_hex(@msg) is export {
+ sha256_hex(@msg.join);
+ return nqp::p6box_s($PD.sha_hex());
+}
+
+sub sha256_print(@sum) is export {
+ sha256_sum(@sum);
+ return nqp::p6box_s($PD.sha_print());
+}
# vim: ft=perl6
Please sign in to comment.
Something went wrong with that request. Please try again.