Click here to get back home

Net::SSH::Perl::Cipher Problem.

 HomeNewsGroups | Search | About
 comp.lang.perl.modules    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Net::SSH::Perl::Cipher Problem. Prasad 06-10-2005
Posted by Prasad on June 10, 2005, 1:51 am
Please log in for more thread options


I am using the following script. Its encrypting the data but when i
decrypt, i am not getting the original text again.


use Net::SSH::Perl::Cipher;
$key = "0123456789ABCDEF12345678";
$plaintext="Shankar";
my $cipher = Net::SSH::Perl::Cipher->new('D­ES3',$key);
my $ciphertext = $cipher->encrypt($plaintext);
print "The Plain text is : [$plaintext]\n";
print "The Cipher is : [$cipher]\n";
print "The Cipher text is : [$ciphertext] \n";
my $recoveredtext = $cipher->decrypt($ciphertext);
print "The recovered text is : [$recoveredtext]\n";


Output
The Plain text is : [Shankar]
The Cipher is : [Net::SSH::Perl::Cipher::DES3=­HASH(0x708fc)]
The Cipher text is : [莋ϪþqK]
The recovered text is : [Üdh´¢¶·]


Thanks in Advance.



Posted by Sisyphus on June 12, 2005, 3:34 pm
Please log in for more thread options



I am using the following script. Its encrypting the data but when i
decrypt, i am not getting the original text again.


use Net::SSH::Perl::Cipher;
$key = "0123456789ABCDEF12345678";
$plaintext="Shankar";
my $cipher = Net::SSH::Perl::Cipher->new('D­ES3',$key);
my $ciphertext = $cipher->encrypt($plaintext);
print "The Plain text is : [$plaintext]\n";
print "The Cipher is : [$cipher]\n";
print "The Cipher text is : [$ciphertext] \n";
my $recoveredtext = $cipher->decrypt($ciphertext);
print "The recovered text is : [$recoveredtext]\n";


Output
The Plain text is : [Shankar]
The Cipher is : [Net::SSH::Perl::Cipher::DES3=­HASH(0x708fc)]
The Cipher text is : [èZ<ϪþqK]
The recovered text is : [Üdh´¢¶·]
---------------------------------------------------

Don't forget to 'use warnings;'.

Could it be that $plaintext needs to be 8 (or a multiple of 8) bytes long ?
It shouldn't matter, but as a test try with:
$plaintext = 'Shankar1";

I don't have this module so am unable to test it out myself. I was, however,
able to run the following script:

use warnings;
use Crypt::DES_EDE3;
$key = "0123456789ABCDEF12345678";
$plaintext="Shankar";
$plaintext .= "";
my $cipher = Crypt::DES_EDE3->new($key);
my $ciphertext = $cipher->encrypt($plaintext);
print "The Plain text is : [$plaintext]\n";
print "The Cipher is : [$cipher]\n";
print "The Cipher text is : [$ciphertext] \n";
my $recoveredtext = $cipher->decrypt($ciphertext);
print "The recovered text is : [$recoveredtext]\n";

That produced the following for me:

The Plain text is : [Shankar ]
The Cipher is : [Crypt::DES_EDE3=HASH(0x3f5060)]
The Cipher text is : [èZ<ϪþqK]
The recovered text is : [Shankar ]

I think that demonstrates that the Net::SSH::Perl encryption subroutine is
functioning correctly (assuming that null-padding is the appropriate
action), but that there's something amiss with the Net::SSH::Perl decryption
subroutine.

Cheers,
Rob





Similar ThreadsPosted
RFC: Crypt::Skip32 - 32-bit block cipher based on Skipjack September 23, 2007, 6:15 am
Problem with Net::SSH Perl June 30, 2005, 8:31 am
Problem with Net::SSH::Perl module December 22, 2004, 12:38 pm
Problem using C module in perl January 5, 2006, 5:03 am
Net::SSH::Perl remoteinteract.pl Problem January 9, 2006, 4:19 am
problem in telnet using perl December 27, 2007, 11:22 pm
Problem installing certain PERL modules October 15, 2004, 4:47 am
Perl DBI Oracle Problem with Apache 2.0.46 January 19, 2005, 2:29 am
DynaLoader problem, (Extending Perl) June 2, 2005, 2:14 pm
libwww-perl-5.805 install problem on OS X 10.3 March 13, 2006, 10:12 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap