diff --git a/noid.py b/noid.py index 6277354..38b2bcb 100644 --- a/noid.py +++ b/noid.py @@ -182,7 +182,17 @@ class Minter(Persistent): # 7. init checkchar to the value of xdig[sum % alphacount] # 8. return the concat of id and checkchar is lastchar equal to '+' or checkchar # 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__":