socket.io with strange timestamp format (?)

1.2k Views Asked by At

I see requests to socket.io containing parameter t to be like LZywzeV, LZz5lk7 and similar.

All examples that i found so far used second- or millisecond-based UNIX timestamps.

Has anyone ever seen a timestamp format like this? (It is not base64-encoded).

2

There are 2 best solutions below

1
On BEST ANSWER

I started looking a site that uses Socket.io today, and got the same problem, trying to look for the protocol definition was useless.

I figured this format is something called yeast

TBH, really don't know why people invent this sort of things instead of use base64(timestamp.getBytes()) pseudocode instead.

A yeast decode algorithm in Python is as follow:

from datetime import datetime

a='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_'
b={a[i]: i for i in range(len(a))}

c=0
for d in "LZywzeV":
  c=c*64+b[d]

print(c)
print(datetime.fromtimestamp(c/1000))

The output of that code is:

1481712065055
2016-12-14 07:41:05
0
On

to @jeremoquai: It is easy, is matter of invert the algorithm:

def yeast(d):
  r=""
  while d!=0:
    r='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_'[d&63]+r
    d>>=6
  return r

so, if you run

yeast(1481712065055)

it returns LZywzeV