This may be one of the following:
This is a string specifying one of the following
When the last block of plaintext is shorter than the block size, it must be
padded before encryption. Padding should permit a safe unpadding after
decryption. Crypt::GCrypt currently supports two methods:
|secure||If this option is set to a true value, all data associated with this cipher will be put into non-swappable storage, if possible.|
|enable_sync||Enable the CFB sync operation.|
This method must be called before any call to setkey() or setiv(). It prepares
the cipher for encryption or decryption, resetting the internal state.
$cipher->setkey(my secret key);
Encryption and decryption operations will use this key until a different
one is set. If your key is shorter than the ciphers keylen (see the
keylen method) it will be zero-padded, if it is longer it will be
Set the initialisation vector for the next encrypt/decrypt operation.
If IV is missing a standard IV of all zero is used. The same IV is set in
newly created cipher objects.
$ciphertext = $cipher->encrypt($plaintext);
This method encrypts $plaintext with $cipher, returning the
corresponding ciphertext. The output is buffered; this means that
youll only get multiples of $ciphers block size and that at the
end youll have to call finish().
$ciphertext .= $cipher->finish;
$plaintext .= $cipher->finish;
The CBC algorithm must buffer data blocks internally until there are even
multiples of the encryption algorithms blocksize (typically 8 or 16 bytes).
After the last call to encrypt() or decrypt() you should call finish() to flush
the internal buffer and return any leftover data. This method will also take care
of padding/unpadding of data (see the padding option above).
$plaintext = $cipher->decrypt($ciphertext);
The counterpart to encrypt, decrypt takes a $ciphertext and produces the
original plaintext (given that the right key was used, of course).
The output is buffered; this means that youll only get multiples of $ciphers
block size and that at the end youll have to call finish().
print "Key length is " . $cipher->keylen();
As their name implies, block ciphers operate on blocks of data. This
method returns the size of this blocks in bytes for this particular
cipher. For stream ciphers 1 is returned, since this implementation
does not feed less than a byte into the cipher.
Apply the CFB sync operation.
digest_algo_available()Determines whether a given digest algorithm is available in the local gcrypt installation:
my $digest = Crypt::GCrypt->new( type => digest, algorithm => sha256, );
The type argument must be digest and algorithm is required too. See below for a description of available algorithms and other initialization parameters:
Once youve got your digest object the following methods are available:
algorithm Depending on your available version of gcrypt, this can be one of the following hash algorithms. Note that some gcrypt installations do not implement certain algorithms (see digest_algo_available()).
<B>md4B> <B>md5B> <B>ripemd160B> <B>sha1B> <B>sha224B> <B>sha256B> <B>sha384B> <B>sha512B> <B>tiger192B> <B>whirlpoolB> secure If this option is set to a true value, all data associated with this digest will be put into non-swappable storage, if possible. hmac If the digest is expected to be used as a keyed-Hash Message Authentication Code (HMAC), supply the key with this argument. It is good practice to ensure that the key is at least as long as the digest used.
digest_length()my $len = $digest->digest_length();
Feeds data into the hash context. Once you have called read(), this method cant be called anymore.
reset()Re-initializes the digest with the same parameters it was initially created with. This allows write()ing again, after a call to read().
clone()Creates a new digest object with the exact same internal state. This is useful if you want to retrieve intermediate digests (i.e. read() from the copy and continue write()ing to the original).
read()my $md = $digest->read();
Completes the digest and return the resultant string. You can call this multiple times, and it will return the same information. Once a digest object has been read(), it may not be written to.
libgcrypt is initialized with support for Pthread, so this module should be thread safe.
Crypt::GCrypt::MPI supports Multi-precision integers (bignum math) using libgcrypt as the backend implementation.
There are no known bugs. You are very welcome to write mail to the author (firstname.lastname@example.org) with your contributions, comments, suggestions, bug reports or complaints.
Alessandro Ranellucci <email@example.com>
Daniel Kahn Gillmor (message digests) <firstname.lastname@example.org>
Copyright (c) Alessandro Ranellucci. Crypt::GCrypt is free software, you may redistribute it and/or modify it under the same terms as Perl itself.
This module was initially inspired by the GCrypt.pm bindings made by Robert Bihlmeyer in 2002. Thanks to users who give feedback and submit patches (see Changelog).
This software is provided by the copyright holders and contributors as is and any express or implied warranties, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose are disclaimed. In no event shall the regents or contributors be liable for any direct, indirect, incidental, special, exemplary, or consequential damages (including, but not limited to, procurement of substitute goods or services; loss of use, data, or profits; or business interruption) however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence or otherwise) arising in any way out of the use of this software, even if advised of the possibility of such damage.
|perl v5.20.3||CRYPT::GCRYPT (3)||2013-05-25|