develooper Front page | perl.beginners | Postings from May 2007

Re: Crypt::GCrypt error on new method

Thread Previous
Mike Blezien
May 23, 2007 08:52
Re: Crypt::GCrypt error on new method
Message ID:

----- Original Message ----- 
From: "JOHN FISHER" <>
To: <>
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 line 5.

Any ideas?

  use Crypt::GCrypt;

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

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

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

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

  $plaintext  = $cipher->decrypt($ciphertext);

Shouldn't that be

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


Thread Previous Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About