Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Implementation of PPM filename checksum used when Flipnotes are saved into storage
checksum_dict = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
def calc_check_digit(filename):
sumc = int(filename[0:2], 16)
for i in range(1, 16):
char = ord(filename[i])
sumc = (sumc + char) % 256
return checksum_dict[sumc % len(checksum_dict)]
def set_check_digit(filename):
digit = calc_check_digit(filename)
filename = digit + filename[1:]
return filename
# Example
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment