[exim] Decode base 62 message ID

Kezdőlap
Üzenet törlése
Válasz az üzenetre
Szerző: Björn Keil
Dátum:  
Címzett: exim-users
Tárgy: [exim] Decode base 62 message ID
Hello,

I am trying to find a way to decode the base 62 encoding used for the
date in the message ID. I've written a little python program, but the
results don't seem quite right:

I started out with the assumption that the numbers were given big endian
(as any human readable number) and that the values of digits were their
own, a -> z => 10 -> 35 and A -> Z => 36 -> 61. Was any of those
assumptions wrong? Besides, is the time used the local time or UTC?

Example: Message 1Ju5ft-00008c-Sp was sent at 2008-05-08 14:56:41. For
1Ju5ft the program below returns 1588237971. And according to /bin/date
that's 2020-04-30 09:12:51+0000.

Could anyone help with that?

Thanks
Björn

#!/usr/bin/python
import sys
def valueOf (letter):
    if (letter.islower()):
        return ord(letter) - 87
    elif (letter.isupper()):
        return ord(letter) - 29
    else:
        return ord(letter) - 48



encoded = sys.argv[1]
decoded = 0
round = 0
for i in range(len(encoded) - 1, -1, -1):
    decoded += valueOf(encoded[i]) * pow (62, round)
    round +=  1


print decoded
#END