Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^3: String differs from printing to STDOUT and printing to file

by rjt (Curate)
on Oct 23, 2019 at 11:05 UTC ( [id://11107887]=note: print w/replies, xml ) Need Help??


in reply to Re^2: String differs from printing to STDOUT and printing to file
in thread String differs from printing to STDOUT and printing to file

encrypt() seems to NUL pad the string to the required block size:

  $plaintext .= "\0" x $trail;

That's where your NULs are coming from. If you know that trailing \0s are not ever valid, you can strip them right before your return in decrypt():

$plaintext =~ s/\0+$//;

On the other hand, if trailing NUL are a legitimate possibility, you will have to come up with a different plan, such as encoding the real length within your plaintext in encrypt() so you can trim it in the decrypt() sub.

Replies are listed 'Best First'.
Re^4: String differs from printing to STDOUT and printing to file
by cboesch (Initiate) on Oct 23, 2019 at 11:30 UTC
    Ok that's it.
    Thanks a lot!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2024-04-25 14:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found