Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

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

by rjt (Curate)
on Oct 23, 2019 at 11:05 UTC ( #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
Node Status?
node history
Node Type: note [id://11107887]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (5)
As of 2020-03-29 19:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    To "Disagree to disagree" means to:









    Results (171 votes). Check out past polls.

    Notices?