Dear monks it me again
I am working on a program that you input the data to do a ftp connection to a server the data right now is $server, $user, $password, so I save these data on a plain text and then I encrypt the data on the plain text file, my problem is when I try to read this data and I dont why is not reading the data, I hope you guys can help me
thanks
this is the part where I encrypt the 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);
and this is the one that read the data from the encrypt data
#!/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";
I really hope you guys can help me!
thanks!