SHA-1 Class

· Sep 7, 11:39 AM

I’ve added a SHA1 class to the file downloads. It is a REALbasic implementation of the SHA-1 hash function that should work on all platforms.

It proved to be an interesting exercise in squeezing performance from REALbasic code. The main performance improvements came from moving everything inline, and computing all of the bit-shifts bare-hands. An inline pragma allows you to see the difference. Moving the declaration of an array from inside a loop also had a measurable impact.

Among the tricks that did not work were loop-unrolling and elimination of an extra loop (the initialization of the block W). Also, SHA-1 is written for big-endian data, so one might look for improvements in reading data. In the end, I found that setting BinaryStream.LittleEndian to false to be the best approach.

Download

---

Commenting is closed for this article.