How safe is this?

Chris Muller chris at funkyobjects.org
Mon Jun 5 20:02:53 UTC 2006


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