Crap, silly me... why do I always notice these things only after I've hit send?
On 24/02/17 17:17, Peter Lebbing wrote: > The following Python: > >>>> from posixcksum import PosixCkSum >>>> from base64 import b64encode >>>> crc, _ = PosixCkSum.sum_whole(bytearray(b'123456789')) >>>> b64encode(crc.to_bytes(4,byteorder='big'))[:4] > b'N3pg' Let's make that: >>> from posixcksum import PosixCkSum >>> from base64 import b64encode >>> crc, _ = PosixCkSum.sum_whole(bytearray(b'123456789')) >>> print(b64encode(crc.to_bytes(4,byteorder='big'))[:6]) b'N3pgEQ' > $ printf $(printf '%08x' $(echo -n 123456789 | cksum | cut -d' ' -f1) | sed > 's/../\\x\0/g')|base64|cut -b-4 > N3pg And this one: $ printf $(printf '%08x' $(echo -n 123456789 | cksum | cut -d' ' -f1) | sed 's/../\\x\0/g')|base64|cut -b-6 N3pgEQ Oh, and by the way, when the python module is invoked as the main module, it mimics the working of cksum, so the following two are roughly equivalent: $ cksum *.c $ posixcksum.py *.c HTH, Peter. -- I use the GNU Privacy Guard (GnuPG) in combination with Enigmail. You can send me encrypted mail if you want some privacy. My key is available at <http://digitalbrains.com/2012/openpgp-key-peter>
signature.asc
Description: OpenPGP digital signature
_______________________________________________ Gnupg-users mailing list Gnupg-users@gnupg.org http://lists.gnupg.org/mailman/listinfo/gnupg-users