Created
April 12, 2016 02:01
-
-
Save mipsparc/64dccb3535466787dc637926d6777ada to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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