How to detect SHA Git identifier in text

A Git SHA identifier looks like this 351e11dac558a764ba83f89c6598151d2dbaf904, it is a long hexadecimal number. But how should this be detected in the text? Find "words" that contain only 0-9, af and are at least 20 characters long? But how to distinguish SHA identifiers from normal words ?

+5
source share
1 answer

Yes, your approach will work. However, remember that SHA1 is a general algorithm (not git specific), so your text may contain other SHA1 hashes, which will also contain hexadecimal strings with six characters.

+1
source

All Articles