Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^2: Weird error with Cryprt::Blowfish and Crypt::DES

by Beechbone (Pilgrim)
on Oct 21, 2004 at 11:36 UTC ( #401127=note: print w/ replies, xml ) Need Help??


in reply to Re: Weird error with Cryprt::Blowfish and Crypt::DES
in thread Weird error with Cryprt::Blowfish and Crypt::DES

Got it:

Perl: a7 53 64 81 c6 0a 30 b9 C: c2 a7 53 64 c2 81 c3 86 0a 30 c2 b9
So the internal strings of Net::SSH::Perl got "infected" with the UTF-8 bit. Seems some of the strings it gets are declared in a "use utf8" area (but are 7bit themselves).

Now, as what Net::SSH::Perl gives to Cypher::* are binary data (byte strings) regardless of the input strings (character strings), how would I best fix that?

I see three possibilities:

1) Fix Net::SHH::Perl to make a difference between character strings it gets and the byte strings it uses to build the SSH protocol in it.

2) Change our code to disable the UTF8 bit on every string that is given to Net::SSH::Perl.

3) Change Crypt::* to turn the UTF8 bit off on data that is 8 characters long.

I'd say #1 would be the cleanest way and #3 the fastest. As we have a deadline of this afternoon for a complete program run, I will implement #3 as a workaround fast. But, what should we do on the long run?

BTW: Thank you to all who helped, tried to help, or would have helped if they could.


Update:

HELP, How DO I do this? I've got the String as above labeled 'Perl' with UTF8 on. When I just disable the flag, I get the 'bad' String, as labelled with 'C'. So how do I convert that string to a string of 8 bytes with the values as they should be?


Update2:

Ok, I found that, too. utf8::downgrade($data);


Search, Ask, Know


Comment on Re^2: Weird error with Cryprt::Blowfish and Crypt::DES
Select or Download Code
Re^3: Weird error with Cryprt::Blowfish and Crypt::DES
by Anonymous Monk on Jul 25, 2008 at 17:36 UTC
    Thank you soooo much. I worked hours on that problem without finding a reason or solution for that. I read my plaintext string from a xml file and "utf8::downgrade($data);" did the trick.
      Thanks... How to apply the explanation wasn't total clear to me since I was originally try to hack up the DES.pm to find where the data was being passed incorrectly before I found this thread. Attached is a clear example:
      use utf8; my $username = $connection->{'username'}; my $password = $connection->{'password'}; my $ip = $connection->{'ip'}; chomp( $username , $password , $ip ); utf8::downgrade($username); utf8::downgrade($password); my $ssh = Net::SSH::Perl->new($ip , port => 'ssh' ); $ssh->login($username, $password); my($out, $err) = $ssh->cmd($cmd || "ls -l"); print $out;
      I am having this exact same problem, but don't understand how you implemeneted your fix. Where are you adding 'utf8::downgrade' because when I add it to the data I send as the username to Net::SSH::Perl it sends the data as '1'. I know this is an old thread but hopefully someone will know what I need to do to fix this. Thanks
Re^3: Weird error with Cryprt::Blowfish and Crypt::DES
by druidmatrix (Acolyte) on May 07, 2010 at 04:42 UTC

    Thank you very much for this solution. I had the same issue with "input must be 8 bytes long".

    Strangely enough, I seem to only get this problem when I use strings coming from XML::Simple (XML::Parser), not when I try to run the same commands on CLI or from a different script that also uses Net::SSH::Perl, but gets the parameters from CLI args.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://401127]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (8)
As of 2014-07-11 03:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (217 votes), past polls