SMB
view release on metacpan or search on metacpan
lib/SMB/Crypt.pm view on Meta::CPAN
return permute([ @$r, @$l ], $des_perm6 );
}
sub des_crypt56 ($$;$) {
my $data = shift // die "No 8-byte data to crypt";
my $str = shift // die "No 7-byte key to crypt";
my $forw = shift // 1;
if (has_Crypt_DES()) {
return Crypt::DES->new(des_str_to_key($str))->encrypt($data);
}
my $arr = [ map { ord($_) } split '', $data ];
my $key = [ map { ord($_) } split '', des_str_to_key($str) ];
my $arrb = [];
my $keyb = [];
for my $i (0 .. 63) {
$arrb->[$i] = $arr->[$i / 8] & (1 << (7 - $i % 8)) ? 1 : 0;
$keyb->[$i] = $key->[$i / 8] & (1 << (7 - $i % 8)) ? 1 : 0;
lib/SMB/Crypt.pm view on Meta::CPAN
my $digest1 = md4($data);
my $digest2 = md5($data);
=head1 ABSTRACT
This module provides fallback implementations for DES, MD4 and MD5 in
pure perl to reduce dependence on non-standard perl modules.
However it is recommended to install L<Crypt::DES>, L<Digest::MD4> and
L<Digest::MD5> modules to get improved performance.
=head1 EXPORTED FUNCTIONS
By default, functions B<des_crypt56>, B<md4>, B<md5> and B<hmac_md5> are exported using the standard L<Exporter> mechanism.
=over 4
=item des_crypt56 EIGHT_BYTE_INPUT SEVEN_BYTE_KEY_STR [FORWARD=1]
Returns output of eight bytes that is a permutation of the input according to a key.
If L<Crypt::DES> is found, it is used, otherwise pure perl fallback implemenation is used.
=item md4 DATA
Returns digest of 16 bytes, similar to Digest::MD4::md4.
If L<Digest::MD4> is found, it is used, otherwise pure perl fallback implemenation is used.
=item md5 DATA ...
Returns digest of 16 bytes, similar to Digest::MD5::md5.
( run in 0.237 second using v1.01-cache-2.11-cpan-9a3d99fc6dc )