ONO::Lib::Data::Crypt

ONO_Lib_Data_Crypt allows to crypt data, which is mostly useful when creating password hashes for example.

Functions

decryptrc4();

Decrypt a password or a string using RC4. Not recommended for passwords, better use SHA instead.

ONO::Lib::Data::Crypt->decryptrc4( $password, $input );

detect_openssl();

Detect the location of the openssl binary

ONO::Lib::Data::Crypt->detect_openssl( );
returns: $openssl

encryptrc4();

Encrypt a password or a string using RC4. Not recommended for passwords, better use SHA instead.

ONO::Lib::Data::Crypt->encryptrc4( $password, $input );
returns: ($status,$result)

encryptrc4file();

Encrypt a file using RC4.

ONO::Lib::Data::Crypt->encryptrc4file( $password, $input, $output, $switches );

openssl_crt_decode();

Decode a CRT file, using openssl

ONO::Lib::Data::Crypt->openssl_crt_decode( );
returns: ONO::IO->exec("$openssl x509 -in $vpath/$file -text -noout")

pwdchk();

ONO_Lib_Data_Crypt->pwdchk($password,$password_hash) will check if $password and $password_hash match.

ONO::Lib::Data::Crypt->pwdchk( $password, $hash );
returns: $valid

pwdhash();

ONO_Lib_Data_Crypt->pwdhash($password) will return the hash for $password, using random salt (great for generating a password hash)

ONO_Lib_Data_Crypt->pwdhash($password,$salt) will return the hash for $password, using $salt (can be used to see if a hash is valid, this is also used by pwdchk - see below)

ONO's max hash length is 32 chars.

encryption types:

-default standard perl crypt for 8 char passwords, generating
a 13 char hash (2 salt + 11 data)

-MD5 hash starting by $1$... currently not supported

-Blowfish hash starting by $2$... or $2a$... are not supported,
as Blowfish is for encryption and not for hashing

-SHA hash starting by $5$... (256) or $6$... (512). The latter
one is default on systems with installed Crypt::Password (recommended).

length 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789

sha256 $5$AA$I7/f0PluP/ZHZU.bJPe7mGd/8Wa9yVWcPXSD40ClWHB -> 50 required sha512 $6$AA$ctPS1XAv.jVOmzBozr7JJtTV1r5oZR9Nh6YjsSQbg7tXweluVh3FBu8riEPQSLP.leDtft5aVmLdMnAidJnxa/ -> 92 required

ONO::Lib::Data::Crypt->pwdhash( $password, $salt, $algo );
returns: $hash

salt();

Generate a password salt, return it as a string.

ONO::Lib::Data::Crypt->salt( );
returns: join '', ('.', '/', 0..9, 'A'..'Z', 'a'..'z')[rand 64, rand 64]

stronghash();

Generate a strong password hash.

ONO::Lib::Data::Crypt->stronghash( $password, $salt, $algo );
returns: $stronghash

strongtest();

Test if strong password encryption is working on the current system.

ONO::Lib::Data::Crypt->strongtest( );

strongtest_error();

Test if strong password encryption is working on the current system.

ONO::Lib::Data::Crypt->strongtest_error( );
returns: &stronghash("","testpass","AA","sha512")

Sub-Modules

none

Dependencies

Optional CPAN Modules

The following modules may be optional, but they are probably required for all features to work properly.

Crypt::Password
Crypt::RC4
MIME::Base64