Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Which Crypt::XXX should I use ?

by pcouderc (Monk)
on Feb 17, 2016 at 10:01 UTC ( [id://1155450]=perlquestion: print w/replies, xml ) Need Help??

pcouderc has asked for the wisdom of the Perl Monks concerning the following question:

Hi monks,
I need a (very) simple crypt utility and I have tried Crypt::CBC.
I have a problem with it in :

$cipher->decrypt_hex($ciphertext)
in the case $ciphertext is wrong : I get an error (Ciphertext does not begin with a valid header for 'salt') and the process stops. So :

  • 1- how to process the case of error ?I see nothing in the doc
  • 2- what is the simplest Crypt::XXX to achieve my goal

Thanks all
PC

Replies are listed 'Best First'.
Re: Which Crypt::XXX should I use ?
by Tux (Canon) on Feb 17, 2016 at 11:38 UTC

    You might get better results with CryptX, but as you did not show the failing $cyphertext, no-one here can check if that actually works better.


    Enjoy, Have FUN! H.Merijn

      Thank you.
      eval does the job.
      Cryptx seems very fine, but it is a not necessary as it includes Crypt::CBC which is enough for my needs.

Re: Which Crypt::XXX should I use ?
by hippo (Bishop) on Feb 17, 2016 at 10:20 UTC
    how to process the case of error ?

    Ideally you would check the input ($ciphertext) to determine if it is valid before considering whether to pass it to the decryption method. If that isn't feasible for any reason then just trap the error with eg. Try::Tiny or eval.

      Thank you, I do that. The point is that I have to learn to process errors.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1155450]
Front-paged by Arunbear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2024-04-25 07:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found