First working implementation of the _checkchar method

This commit is contained in:
2026-07-17 09:36:35 +02:00
parent 0fffca4e9a
commit 8d2f0a6519
+11 -1
View File
@@ -182,7 +182,17 @@ class Minter(Persistent):
# 7. init checkchar to the value of xdig[sum % alphacount] # 7. init checkchar to the value of xdig[sum % alphacount]
# 8. return the concat of id and checkchar is lastchar equal to '+' or checkchar # 8. return the concat of id and checkchar is lastchar equal to '+' or checkchar
# 9. return None # 9. return None
pass if id is None:
return None
lastchar = id[-1]
sum = 0
for idx, char in enumerate(id[:-1], 1):
sum += idx * (self.legalstring.index(char) if self.legalstring.index(char) else 0)
checkchar = self.xdig[sum % self.alphacount]
if lastchar == "+" or lastchar == checkchar:
return id[:-1] + checkchar
else:
return None
if __name__ == "__main__": if __name__ == "__main__":