Add SHA1 implementation to avoids creating string objects; make this Python 3 compatible