Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^3: AES Interoperability between Perl and C#

by ikegami (Patriarch)
on Nov 17, 2005 at 22:22 UTC ( [id://509619]=note: print w/replies, xml ) Need Help??


in reply to Re^2: AES Interoperability between Perl and C#
in thread AES Interoperability between Perl and C#

There's two common ways of storing a string.

1) NUL-terminated.

The end of the string is marked by the first occurance of a NUL character.

Pro: The string can be of any length.
Con: The string cannot contain NULs.

2) PASCAL string.

Named after the programming language. The length of the string is stored along with the string itself.

Pro: The string can contain any character.
Con: The size of the length field limits the size of the string.

Thelonius chose the latter. And in this case, the limit on the string length is (2^32)-1 (over 2 billion) since he's using a 32 bit signed int for the length field.

  • Comment on Re^3: AES Interoperability between Perl and C#

Replies are listed 'Best First'.
Re^4: AES Interoperability between Perl and C#
by jpfarmer (Pilgrim) on Nov 17, 2005 at 22:32 UTC

    So by commenting that out, I'm forcing the NUL-terminated mode?

      It depends on what you are encrypting. If you are encrypting many thing, you need a way of telling how long each thing is so you can seperate them once the ciphertext is decrypted.

      If you're encrypting more than just a string, You'll need to add a NUL if you remove the length. You have to use one or the other (or some other alternative) in order to know where the string ends and the next thing in the plaintext start.

      If the ciphertext only contains the string, you don't need either mechanism since the length of the string will be deduced by the length of the ciphertext.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (3)
As of 2025-06-23 18:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.