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 :

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 (Archbishop) 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.