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!

In reply to Problem: Cant find mistake !!! by padawan_linuxero

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.