Hallo,
ich hab nun die Verschlüssung mit dem Modul http://search.cpan.org/dist/Crypt-CBC/CBC.pm gemacht bzw. ich versuche es.
Das 0815-Beispiel klappt einwandfrei.
  
  use Crypt::CBC;  
  $cipher = Crypt::CBC->new( -key    => 'my secret key',  
                             -cipher => 'Blowfish'  
                            );  
  
  $ciphertext = $cipher->encrypt("This data is hush hush");  
  $plaintext  = $cipher->decrypt($ciphertext);  
Nun will ich die verschlüsselten Daten in einer DB ablegen und gehe wie folgt vor:
my $key = "x";  
my $cipher = Crypt::CBC->new( -key    => $key,  
                             -cipher => 'Blowfish'  
                            );  
my $ciphertext = $cipher->encrypt($plaintext);  
$ciphertext = encode('UTF-8', $ciphertext);  
my $sql = qq{INSERT INTO data (data) VALUES (?));
Das klappt ebenfalls.
Was aber nicht klappt ist das entschlüsseln der Daten:
  
$main::dbh->do("set character set utf8");  
$main::dbh->do("set names utf8");  
DB Abfrage für ciphertext (die erfolgreich ist) ...  
$ciphertext = decode('UTF-8', $ciphertext);  
my $key = "x";  
my $cipher = Crypt::CBC->new( -key    => $key,  
                             -cipher => 'Blowfish'  
                            );  
my $plaintext  = $cipher->decrypt($ciphertext);  
Ergebnis:
In $plaintext steht Müll drin, also weder der orginale Plaintext nocht der Ciphertext.
Jemand eine Idee?
ciao
H1N1
 nicht angemeldet
 nicht angemeldet