skids/perl6sum/lib/Sum/MD
perl6sum src
NAME
Sum::MD
SYNOPSIS
use Sum::MD;
class myMD5 does Sum::MD5 does Sum::Marshal::Raw { }
my myMD5 $a .= new();
$a.finalize("123456789".encode('ascii')).say;
# 50479014739749459024317001064922631435
# Usage is basically the same for MD4, MD4ext, RIPEMD128,
# RIPEMD160, RIPEMD256 and RIPEMD320.
DESCRIPTION
Using C<Sum::MD> defines roles for generating types of C<Sum> that
calculate the MD series of message digests (MD2, MD4, MD5) and
close variants. MD6 is not yet implemented.
Note that many of these algorithms are considered deprecated for new
applications, and insecure in some current applications.
These sums require a small but significant memory profile while not
finalized, so care must be taken when huge numbers of concurrent
instances are used.
NOTE: This implementation is unaudited and is for experimental
use only. When audits will be performed will depend on the maturation
of individual Perl6 implementations, and should be considered
on an implementation-by-implementation basis.
ROLES
(head2) role Sum::MD4 does Sum::MDPad
role Sum::MD4ext does Sum::MDPad
role Sum::MD5 does Sum::MDPad
role Sum::RIPEMD128 does Sum::MDPad
role Sum::RIPEMD160 does Sum::MDPad
role Sum::RIPEMD256 does Sum::MDPad
role Sum::RIPEMD320 does Sum::MDPad
Classes using these roles behave as described in C<Sum::MDPad>,
which means they have rather restrictive rules as to the type
and number of provided addends when used with C<Sum::Marshal::Raw>.
Mixing a C<Sum::Marshal::Block> role is recommended except for
implementations that wish to optimize performance.
(head2) role Sum::MD2 does Sum
The C<Sum::MD2> role is used to create a type of C<Sum>
that calculates an MD2 message digest. These digests should only
be used for compatibility with legacy systems, as MD2 is not
considered a cryptographically secure algorithm.
The resulting C<Sum> expects 16-byte blocks as addends. Currently
that means a punned C<Buf> with 16 elements. Passing a shorter Buf
may be done once, before or during finalization. Attempts to provide
more blocks after passing a short block will result in an
C<X::Sum::Final>.
C<Sum::Marshal::Block> roles may be mixed in to allow for accumulation
of smaller addends, to split large messages into blocks, or to allow
for the mixin of the C<Sum::Partial> role.
AUTHOR
Written by Brian S. Julin
COPYRIGHT
Copyright (c) 2012 Brian S. Julin. All rights reserved. This program is
free software; you can redistribute it and/or modify it under the terms
of the Perl Artistic License 2.0.
REFERENCES
SEE ALSO
C<Sum::(pm3)>