Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
filename = 'TEST TXT'
total = 0
for newchar in filename:
#rotate(一番右のビットは一番左に)
total = ((total & 1) << 7) + (total >> 1)
#add
total += ord(newchar)
#桁溢れ防止
total = total & 0xFF
print(format(total, 'b'))
print(format(total, 'x'))
####結果
#$ python3 sfn_checksum.py
#10001111
#8f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.