padawan_linuxero has asked for the wisdom of the Perl Monks concerning the following question:
and this is the one that read the data from the encrypt data#!/usr/bin/perl use strict; use Crypt::Twofish; use Crypt::CBC; my $key = "Super Secret Handshake"; my $cipher = new Crypt::CBC ($key, 'Twofish'); my $plaintext; my $ciphertext; # Open the plain text config file and read the data to encrypt. # print "Give me the server to connect :"; my $server=<STDIN>; chomp($server); print "Give me the user to login :"; my $login=<STDIN>; chomp($login); print "Give me the password to login :"; my $password=<STDIN>; chomp($password); open(PLAINTEXT,">Plain") || print "Error to write to the file"; print PLAINTEXT "$server\|$login\|$password\n"; local $/; $plaintext = <PLAINTEXT>; close(PLAINTEXT); # Using our super-secret key write out the encrypted data. # open(CIPHERTEXT, "> Plain"); #EncryptedConfigFile $ciphertext = $cipher->encrypt($plaintext); $ciphertext = unpack("B*", $ciphertext); # convert the encrypted data + into a string of "0"s and "1"s print CIPHERTEXT $ciphertext; close(CIPHERTEXT);
I really hope you guys can help me! thanks!#!/usr/bin/perl use strict; use Crypt::Twofish; use Crypt::CBC; # You'll need to use the same key that you used to encrypt the file. # my $key = "Super Secret Handshake"; my $cipher = new Crypt::CBC ($key, 'Twofish'); my $ciphertext; my $plaintext; { open(CIPHERTEXT, "Plain"); local $/; $ciphertext = <CIPHERTEXT>; close(CIPHERTEXT); } $ciphertext = pack("B*", $ciphertext); # convert a string of "0"s and + "1"s into the binary encrypted string $plaintext = $cipher->decrypt($ciphertext); chomp($plaintext); my ($server, $username, $password) = split(/\|/, $plaintext); print STDOUT "Server: " . $server . "\n"; print STDOUT "Username: " . $username . "\n"; print STDOUT "Password: " . $password . "\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Problem: Cant find mistake !!!
by elmex (Friar) on Apr 19, 2008 at 17:25 UTC | |
by padawan_linuxero (Scribe) on Apr 19, 2008 at 17:33 UTC | |
by apl (Monsignor) on Apr 19, 2008 at 17:52 UTC |