in reply to Crypt::Simple Passphrase Issue

Looking at the documentation for Crypt::Simple, it is apparently only the encryption phase which takes a passphrase.  Therefore, it appears you will always get your encrypted data successfully decrypted when using decrypt.

That's not to say the passphrase doesn't matter, though.  You can verify that using a different passphrase produces different results:

#!/usr/bin/perl -w + use strict; use warnings; + use Crypt::Simple qw(encrypt decrypt); + my $data1 = encrypt("Here we go", passphrase => 'myTestPhrase'); my $data2 = encrypt("Here we go", passphrase => 'AnotherTestPhrase'); print "Encrypted(1): $data1\n"; print "Encrypted(2): $data2\n"; + my $result1 = decrypt($data1); my $result2 = decrypt($data2); print "Decrypted(1): $result1\n"; print "Decrypted(2): $result2\n";
which produces ...
Encrypted(1): Qf9g4cqQ/6xXgqvcPLJA6u9PZ4jPgegPrsBCsFaPch3LDsaN6TjN6xjL +jebw4yPFNO2rEBTUgISSkiX1v2Aelt4qmHFcd6nF Encrypted(2): qymmKtF/LXb+HIZe6ZCFS8xtLadYkS+09dZ8zxAvL+r9Rw+GjkeBMc8y +e++Yl/s/DxJppvKQm2ToJ78mENTuxcc8fUMrKdZbHuWGiMBxgK0= Decrypted(1): Here we go Decrypted(2): Here we go

s''(q.S:$/9=(T1';s;(..)(..);$..=substr+crypt($1,$2),2,3;eg;print$..$/

Replies are listed 'Best First'.
Re^2: Crypt::Simple Passphrase Issue
by Anonymous Monk on May 17, 2006 at 13:05 UTC
    Thanks Liverpole for the quick reply. But does not that defeat the whole purpose of a passphrase? The data should only be decrypted if the correct passphrase is provided. Otherwise, anybody can read it! Am I missing anything here?

      Crypt::Simple only allows one passphrase per program invocation (or per module it is used in), if you use the passphrase => syntax. Try it maybe with the passfile or prompt option instead.

        I tried the other options but no luck. The problem is I cannot invoke the program twice since it is a TK/Gui based application. My code was a simplified version. Any way to override the referenced value of the passphrase key?