On 11/30/05 9:20 PM, "Phil M" <phil at mobleybros dot com> wrote:
> On Nov 30, 2005, at 7:03 PM, Roph wrote:
>
>> This would probably have a little better distribution
>> characteristics, especially for short strings and run at a
>> comparable speed to what I proposed.
>
> MemoryBlocks are usually quicker than string manipulations, but your
> function looked pretty optimized in that regard.
>
Yes, MemoryBlocks should be used of course. The point of my code was to
provide clear pseudocode to describe an algorithm for implementation in C.
>> I like the LittleEndian tweak for cross-platform compatibility,
>
> You can't forget about cross-platform compatibility! =)
>
> Actually you have to have the Little-Endian value defined because of
> the UShort. Besides giving a better distribution, it also runs
> almost twice as fast in REALbasic as grabbing each byte.
Yes, processing the shorts is great. I wonder about the end-case condition
however in the event that the string has an odd number of bytes and you map
to the string in memory. I'd have to go stare at it some more to be happy
about that.
>
>> and I was unaware that Bitwise offered a ShiftLeft method -- nice
>> to know.
>
> There is a OnesComplement too, but no TwosComplement.
>
Nice to know.
>> I don't see that using "prime numbers" here as opposed to just
>> "moderate size numbers" really gains you anything of consequence,
>> but combining that with the Mod 65521 gets you the better
>> distribution for small strings.
>
> This was just a modified Adler-32 Checksum. I think the normal
> Adler-32 starts with a=1 and b=0 with an option parameter for a to
> take a different value. I just added the prime numbers for a and b
> to give short strings a kick-start.
>
Sure. if you have the Adler32 algorithm or a pointer to it I'd love to see
it. If it's really just this simple, that might be a fine algorithm to use,
and there are already c-coded plugins for it I believe.
>> So, yeah. I could live with this just fine if coded in C.
>
> I am sure that you can find plenty of examples of C/C++ source code
> for this type of algorithm and you can try the REALbasic Plugin SDK
> to make a plugin out of it.
>
> You know I just checked and the Adler-32 Checksum is part of the
> Einhugur e-CryptIt Engine... so there you go. =)
Yep, I knew it was in either eCryptIt or MBS, and I have both. And I've
read enough to know it's probably the best of the canned-hash algorithms out
there for my purpose. What I don't have is a description of the algorithm
to know what it's doing.
> _______________________________________________
> Unsubscribe or switch delivery mode:
> <http://www.realsoftware.com/support/listmanager/>
>
> Search the archives of this list here:
> <http://support.realsoftware.com/listarchives/lists.html>
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>
|