Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

mcrypt_get_key_size(3) [php man page]

MCRYPT_GET_KEY_SIZE(3)							 1						    MCRYPT_GET_KEY_SIZE(3)

mcrypt_get_key_size - Gets the key size of the specified cipher

SYNOPSIS
int mcrypt_get_key_size (int $cipher) DESCRIPTION
int mcrypt_get_key_size (string $cipher, string $mode) The first prototype is when linked against libmcrypt 2.2.x, the second when linked against libmcrypt 2.4.x or 2.5.x. mcrypt_get_key_size(3) is used to get the size of a key of the specified $cipher (in combination with an encryption mode). It is more useful to use the mcrypt_enc_get_key_size(3) function as this uses the resource returned by mcrypt_module_open(3). PARAMETERS
o $cipher -One of the MCRYPT_ciphername constants, or the name of the algorithm as string. o $mode -One of the MCRYPT_MODE_modename constants, or one of the following strings: "ecb", "cbc", "cfb", "ofb", "nofb" or "stream". RETURN VALUES
Returns the maximum supported key size of the algorithm in bytes or FALSE on failure. EXAMPLES
Example #1 mcrypt_get_key_size(3) Example <?php echo mcrypt_get_key_size('tripledes', 'ecb'); ?> The example above shows how to use this function when linked against libmcrypt 2.4.x or 2.5.x. The above example will output: 24 SEE ALSO
mcrypt_get_block_size(3), mcrypt_enc_get_key_size(3), mcrypt_encrypt(3). PHP Documentation Group MCRYPT_GET_KEY_SIZE(3)

Check Out this Related Man Page

Mcrypt(3)						User Contributed Perl Documentation						 Mcrypt(3)

NAME
Mcrypt - Perl extension for the Mcrypt cryptography library SYNOPSIS
use Mcrypt; # Procedural routines $td = Mcrypt::mcrypt_load($algorithm, $algorithm_dir, $mode, $mode_dir); Mcrypt::mcrypt_get_key_size($td); # in bytes Mcrypt::mcrypt_get_iv_size($td); # in bytes Mcrypt::mcrypt_get_block_size($td); # in bytes Mcrypt::mcrypt_init($td, $key, $iv); $encryptedstr = Mcrypt::mcrypt_encrypt($td, $decryptedstr); $decryptedstr = Mcrypt::mcrypt_decrypt($td, $encryptedstr); Mcrypt::mcrypt_end($td); # Object-oriented methods $td = Mcrypt->new( algorithm => $algorithm, mode => $mode ); $keysize = $td->{KEY_SIZE}; $ivsize = $td->{IV_SIZE}; $blksize = $td->{BLOCK_SIZE}; $td->init($key, $iv); $encryptedstr = $td->encrypt($decryptedstr); $decryptedstr = $td->decrypt($encryptedstr); # If the $td goes out of context, # the destructor will do this for you $td->end(); DESCRIPTION
This module wraps the libmcrypt encryption library for easy and convenient use from within perl. Encryption and decryption using a variety of algorithms is as easy as a few simple lines of perl. Exported constants The predefined groups of exports in the use statements are as follows: use Mcrypt qw(:ALGORITHMS); Exports the BLOWFISH DES 3DES GOST CAST_128 XTEA RC2 TWOFISH CAST_256 SAFERPLUS LOKI97 SERPENT RIJNDAEL_128 RIJNDAEL_192 RIJNDAEL_256 ENIGMA ARCFOUR WAKE libmcrypt algorithms. See the mcrypt(3) man page for more details. use Mcrypt qw(:MODES); Exports the CBC ECB CFB OFB bOFB STREAM modes of encryption. See the mcrypt(3) man page for more details. use Mcrypt qw(:FUNCS); Exports the following functions: mcrypt_load, mcrypt_unload, mcrypt_init, mcrypt_end, mcrypt_encrypt, mcrypt_decrypt, mcrypt_get_block_size, mcrypt_get_iv_size, mcrypt_get_key_size. EXAMPLES
# Procedural approach: # create an ecryption descriptor: # ALGORITHM: blowfish (256 bit key + 16 byte IV) # MODE: cfb # The user application has set: # $method to either "encrypt" or "decrypt" # $infile to the input filename # $outfile to the output filename my($td) = Mcrypt::mcrypt_load( Mcrypt::BLOWFISH, '', Mcrypt::CFB, '' ); my($key) = "32 bytes of your apps secret key"; # secret key my($iv) = "16 bytes of rand"; # shared initialization vector Mcrypt::mcrypt_init($td, $key, $iv) || die "Could not initialize td"; print Mcrypt::mcrypt_encrypt($td, $_) while(<>); Mcrypt::mcrypt_end($td); # OO approach of the above except decrypting my($td) = Mcrypt->new( algorithm => Mcrypt::BLOWFISH, mode => Mcrypt::CFB, verbose => 0 ); my($key) = "k" x $td->{KEY_SIZE}; my($iv) = "i" x $td->{IV_SIZE}; $td->init($key, $iv); print $td->decrypt($_) while (<>); $td->end(); AUTHOR
Theo Schlossnagle <jesus@omniti.com> SEE ALSO
The libmcrypt man page: mcrypt(3). Other libmcrypt information is available at http://mcrypt.hellug.gr/. perl v5.12.1 2010-07-05 Mcrypt(3)
Man Page