1 2 3 4 5 6 7 8 9 10 11 12 13 14
| def calculCCC( OO, Q, RRRRRR, EZABPQMCDU): # les paramètres sont de type chaîne, ex : "00"
concatenation = OO + Q + RRRRRR + EZABPQMCDU
ordre = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+" # caractères utilisés pour le codage (37 différents)
a = b = c = 0 # initialisation de a, b et c
for i in range(19): # boucle de 0 à 18, pour chaque index de position dans concatenation
position = ordre.find(concatenation[i]) # on retrouve la position du caractère concatenation[i] dans ordre
a = (1 * a + position) % 37 # calcul du nombre a, "% 37" pour modulo 37
b = (2 * b + position) % 37
c = (4 * c + position) % 37
return ordre[a] + ordre[b] + ordre[c] # on encode a, b et c en leur caractères correspondants, et on concatène le tout |
Partager