Forum Archive

crc32 hash generation

codywu

hi all, i'm pretty much completely new to python and am trying to create a simple extension for use in ulysses.

basically i want to take a clipboard input in this format:

Hamlin, S. A., Henry, T. S., Little, B. P., Lerakis, S., & Stillman, A. E. (2014). Mapping the Future of Cardiac MR Imaging: Case-based Review of T1 and T2 Mapping Techniques. RadioGraphics, 34(6), 1594–1611. http://doi.org/10.1148/rg.346140030

and turn it into:

{Hamlin:2014XX}

where XX is a crc32 hash generated from the latter part of the url at the end (ie. "10.1148/rg.346140030") according to this:
http://support.mekentosj.com/kb/cite-write-your-manuscripts-and-essays-with-citations/universal-citekey#universal-citekey-generation

the javascript example is available here: https://github.com/cparnot/universal-citekey-js

i can do the last name and year parsing quite easily but i'm not sure how to approach the hash generation. can anyone provide assistance?

ccc

binascii.crc32() and zlib.crc32() are both available in Pythonista.

https://stackoverflow.com/questions/30092226/how-to-calculate-crc32-with-python-to-match-online-results