How safe is this?

Ron Teitelbaum Ron at USMedRec.com
Mon Jun 5 23:23:23 UTC 2006


You know it's funny I was so busy thinking about transferring the smallest
possible strings I didn't even consider binary.  Very silly and much better
thanks!

Ron

> From: Chris Muller [mailto:chris at funkyobjects.org]
> Sent: Monday, June 05, 2006 4:03 PM
> 
> Hi Ron, as long as your parsing is perfect, I think this conversion
> would be fine and platform independent.  I would be sure to test your
> code works on numbers that do not have the high order bit set, since
> this would result in a shorter-length of the represented number.  Niels
> Ferguson and Bruce Schneier suggest using little-endian representations
> of control fields in a secure-channel which is why, personally, I use
> ByteArray>>#uint:at: and #uint:at:put: now provided by Cryptography.
> 
> As you know using Strings does introduce the potential for platform
> dependencies; have you considered simply stopping at the ByteArray and
> using binary?
> 
>   yourNumber asByteArray asInteger = yourNumber
> 
> Regards,
>   Chris
> --- Ron Teitelbaum <Ron at USMedRec.com> wrote:
> 
> > Hello all,
> > Can you tell me if this is safe for all platforms?
> > self asByteArray asString asByteArray asInteger = self   ->   true
> > I have a largePositiveInteger that needs to be sent on the wire.  I'm
> > trying
> > to convert to save space the number is 256 bits.
> > The resulting string which is going out is 32bytes which seems to me
> > to be
> > the best that can be done storage wise, will I have any trouble on
> > different
> > platforms when I grab the string and do asByteArray asInteger?
> > Is there a better way to store the number?
> > Thanks,
> > Ron Teitelbaum





More information about the Squeak-dev mailing list