FAQ
I am attempting to use gcrypt using a Perl interface

I have "perl -MCPAN -e 'install Crypt::GCrypt'" and installed it successfully.

I attempted to run the code in Perldoc, but get this error
Can't locate object method "new" via package "GCrypt::Cipher" (perhaps you forgot to load "GCrypt::Cipher"?) at gcrypt_testing.pl line 5.

Any ideas?

=====
use Crypt::GCrypt;

$cipher = GCrypt::Cipher->new(
type => 'cipher',
algorithm => 'aes',
mode => 'cbc'
);
$cipher->start('encrypting');

$cipher->setkey('my secret key');

$cipher->setiv('my init vector');

$ciphertext = $cipher->encrypt('plaintext');
$ciphertext .= $cipher->finish;

$plaintext = $cipher->decrypt($ciphertext);
======Thanks,John

Search Discussions

  • Mike Blezien at May 23, 2007 at 3:52 pm
    ----- Original Message -----
    From: "JOHN FISHER" <John.J.Fisher@slma.com>
    To: <beginners@perl.org>
    Sent: Wednesday, May 23, 2007 10:32 AM
    Subject: Crypt::GCrypt error on new method


    I am attempting to use gcrypt using a Perl interface

    I have "perl -MCPAN -e 'install Crypt::GCrypt'" and installed it successfully.

    I attempted to run the code in Perldoc, but get this error
    Can't locate object method "new" via package "GCrypt::Cipher" (perhaps you
    forgot to load "GCrypt::Cipher"?) at gcrypt_testing.pl line 5.

    Any ideas?

    =====
    use Crypt::GCrypt;

    $cipher = GCrypt::Cipher->new(
    type => 'cipher',
    algorithm => 'aes',
    mode => 'cbc'
    );
    $cipher->start('encrypting');

    $cipher->setkey('my secret key');

    $cipher->setiv('my init vector');

    $ciphertext = $cipher->encrypt('plaintext');
    $ciphertext .= $cipher->finish;

    $plaintext = $cipher->decrypt($ciphertext);
    ======Thanks,John
    =========================================

    Shouldn't that be

    $cipher = Crypt::GCrypt->new( ..... );

    Mike

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupbeginners @
categoriesperl
postedMay 23, '07 at 3:37p
activeMay 23, '07 at 3:52p
posts2
users2
websiteperl.org

2 users in discussion

JOHN FISHER: 1 post Mike Blezien: 1 post

People

Translate

site design / logo © 2022 Grokbase