You also have Digest, which is core#!/usr/bin/env perl use strict; use warnings; # a non-random salt == 'salt' #SHA256 print crypt("secret",'$5$salt'); print "\n"; #SHA512 print crypt("secret",'$66salt'); print "\n"; # Oops, security gone, that is not what I meant # I meant this print crypt("secret",'$6$salt');
for encryption, you can xor, read more here Encryption using perl core functions only.#!/usr/bin/env perl use strict; use warnings; use Digest; my $algo = 'SHA-512'; sub hash { my $string = shift; my $salt; # bless whoever wrote this $salt .= join '',('.','/',(0..9),"a".."z","A".."Z")[rand 64] for ( +1..8); my $hasher = Digest->new($algo); $hasher->add($salt); $hasher->add($string); return $salt . $hasher->b64digest(); } sub checkHash { # First 8 characters are salt my $hash = shift; my $string = shift; my $salt = substr($hash,0,8); my $hasher = Digest->new($algo); $hasher->add($salt); $hasher->add($string); return $hash eq $salt . $hasher->b64digest(); } my $hash = hash('blahblah'); print "match" if checkHash($hash,'blahblah');
In reply to Re: crypto with core modules only
by trippledubs
in thread crypto with core modules only
by morgon
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |