About RemoteString>>checksum:

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

About RemoteString>>checksum:

Stéphane Ducasse
in squeak trunk
Can some of you double check this change from squeaktrunk Name: Files-jcg.27

In squeak
checkSum: aString
        "Construct a checksum of the string.  A three byte number represented as Base64 characters."
        | sum shift bytes |
        sum := aString size.
        shift := 0.
        aString do: [:char |
                (shift := shift + 7) > 16 ifTrue: [shift := shift - 17].
                        "shift by 7 to keep a change of adjacent chars from xoring to same value"
                sum := sum bitXor: (char asInteger bitShift: shift)
        ].
        bytes := ByteArray new: 3.
        sum := sum + 16r10000000000.
        1 to: 3 do: [:ind | bytes at: ind put: (sum digitAt: ind)].
        ^bytes base64Encoded



In pharo

checkSum: aString
        "Construct a checksum of the string.  A three byte number represented as Base64 characters."
| sum shift bytes ss bb |
sum := aString size.
shift := 0.
aString do: [:char |
        (shift := shift + 7) > 16 ifTrue: [shift := shift - 17].
                "shift by 7 to keep a change of adjacent chars from xoring to same value"
        sum := sum bitXor: (char asInteger bitShift: shift)].
bytes := ByteArray new: 3.
sum := sum + 16r10000000000.
1 to: 3 do: [:ind | bytes at: ind put: (sum digitAt: ind)].
ss := ReadWriteStream on: (ByteArray new: 3).
ss nextPutAll: bytes.
bb := Base64MimeConverter mimeEncode: ss.
^ bb contents

Thanks



_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: About RemoteString>>checksum:

Nicolas Cellier
It's same code, but pharo String does not respond to #base64Encoded

Nicolas

2010/1/15 Stéphane Ducasse <[hidden email]>:

> in squeak trunk
> Can some of you double check this change from squeaktrunk Name: Files-jcg.27
>
> In squeak
> checkSum: aString
>        "Construct a checksum of the string.  A three byte number represented as Base64 characters."
>        | sum shift bytes |
>        sum := aString size.
>        shift := 0.
>        aString do: [:char |
>                (shift := shift + 7) > 16 ifTrue: [shift := shift - 17].
>                        "shift by 7 to keep a change of adjacent chars from xoring to same value"
>                sum := sum bitXor: (char asInteger bitShift: shift)
>        ].
>        bytes := ByteArray new: 3.
>        sum := sum + 16r10000000000.
>        1 to: 3 do: [:ind | bytes at: ind put: (sum digitAt: ind)].
>        ^bytes base64Encoded
>
>
>
> In pharo
>
> checkSum: aString
>        "Construct a checksum of the string.  A three byte number represented as Base64 characters."
> | sum shift bytes ss bb |
> sum := aString size.
> shift := 0.
> aString do: [:char |
>        (shift := shift + 7) > 16 ifTrue: [shift := shift - 17].
>                "shift by 7 to keep a change of adjacent chars from xoring to same value"
>        sum := sum bitXor: (char asInteger bitShift: shift)].
> bytes := ByteArray new: 3.
> sum := sum + 16r10000000000.
> 1 to: 3 do: [:ind | bytes at: ind put: (sum digitAt: ind)].
> ss := ReadWriteStream on: (ByteArray new: 3).
> ss nextPutAll: bytes.
> bb := Base64MimeConverter mimeEncode: ss.
> ^ bb contents
>
> Thanks
>
>
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: About RemoteString>>checksum:

Stéphane Ducasse
It does in 11161. Strange, do you have a different version?

Stef

On Jan 15, 2010, at 9:12 PM, Nicolas Cellier wrote:

> It's same code, but pharo String does not respond to #base64Encoded
>
> Nicolas
>
> 2010/1/15 Stéphane Ducasse <[hidden email]>:
>> in squeak trunk
>> Can some of you double check this change from squeaktrunk Name: Files-jcg.27
>>
>> In squeak
>> checkSum: aString
>>        "Construct a checksum of the string.  A three byte number represented as Base64 characters."
>>        | sum shift bytes |
>>        sum := aString size.
>>        shift := 0.
>>        aString do: [:char |
>>                (shift := shift + 7) > 16 ifTrue: [shift := shift - 17].
>>                        "shift by 7 to keep a change of adjacent chars from xoring to same value"
>>                sum := sum bitXor: (char asInteger bitShift: shift)
>>        ].
>>        bytes := ByteArray new: 3.
>>        sum := sum + 16r10000000000.
>>        1 to: 3 do: [:ind | bytes at: ind put: (sum digitAt: ind)].
>>        ^bytes base64Encoded
>>
>>
>>
>> In pharo
>>
>> checkSum: aString
>>        "Construct a checksum of the string.  A three byte number represented as Base64 characters."
>> | sum shift bytes ss bb |
>> sum := aString size.
>> shift := 0.
>> aString do: [:char |
>>        (shift := shift + 7) > 16 ifTrue: [shift := shift - 17].
>>                "shift by 7 to keep a change of adjacent chars from xoring to same value"
>>        sum := sum bitXor: (char asInteger bitShift: shift)].
>> bytes := ByteArray new: 3.
>> sum := sum + 16r10000000000.
>> 1 to: 3 do: [:ind | bytes at: ind put: (sum digitAt: ind)].
>> ss := ReadWriteStream on: (ByteArray new: 3).
>> ss nextPutAll: bytes.
>> bb := Base64MimeConverter mimeEncode: ss.
>> ^ bb contents
>>
>> Thanks
>>
>>
>>
>> _______________________________________________
>> Pharo-project mailing list
>> [hidden email]
>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>>
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project