Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: exim: users

Decode base 62 message ID

 

 

exim users RSS feed   Index | Next | Previous | View Threaded


abgrund at silberdrache

May 8, 2008, 6:10 AM

Post #1 of 5 (270 views)
Permalink
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



--
## List details at http://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/


exim-users at ficos

May 8, 2008, 6:19 AM

Post #2 of 5 (257 views)
Permalink
Re: Decode base 62 message ID [In reply to]

Björn Keil wrote:
> 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?


looks like you swapped upper and lowercase alphas ...
see: http://en.wikipedia.org/wiki/Base_62

Rgds

- Karl


--
## List details at http://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/


graeme at graemef

May 8, 2008, 6:27 AM

Post #3 of 5 (258 views)
Permalink
Re: Decode base 62 message ID [In reply to]

Hi

On Thu, 2008-05-08 at 15:10 +0200, Björn Keil wrote:
> 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 know it's in Perl, but this might help:

perl -e "use Data::ID::Exim; print scalar
localtime(Data::ID::Exim::read_base62('1Ju5ft'));"

Thu May 8 13:56:41 2008

Graeme


--
## List details at http://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/


abgrund at silberdrache

May 8, 2008, 6:37 AM

Post #4 of 5 (256 views)
Permalink
Re: Decode base 62 message ID [In reply to]

Am Donnerstag, den 08.05.2008, 15:19 +0200 schrieb Karl Fischer:
> Björn Keil wrote:
> > 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?
>
>
> looks like you swapped upper and lowercase alphas ...
> see: http://en.wikipedia.org/wiki/Base_62
>

Ah, thank you.

In case anyone cares, here's the corrected version. Just save it as file
ending with .py, make it executable and pass the base 62 number you want
to turn decimal as argument.

#!/usr/bin/python
import sys
def valueOf (letter):
if (letter.islower()):
return ord(letter) - 61
elif (letter.isupper()):
return ord(letter) - 55
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


--
## List details at http://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/


abgrund at silberdrache

May 8, 2008, 6:47 AM

Post #5 of 5 (259 views)
Permalink
Re: Decode base 62 message ID [In reply to]

Am Donnerstag, den 08.05.2008, 14:27 +0100 schrieb Graeme Fowler:

> > 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 know it's in Perl, but this might help:
>
> perl -e "use Data::ID::Exim; print scalar
> localtime(Data::ID::Exim::read_base62('1Ju5ft'));"
>
> Thu May 8 13:56:41 2008
Thank you.
I am alergic to perl and never learned it so far (even though I use perl
regular expressions a lot).
But this library may prove helpful.


--
## List details at http://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/

exim users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.