4

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).

AsconX
  • 161
  • 1
  • 15

2 Answers2

2

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
Victor
  • 46
  • 2
  • thanks for the explanation : do you have a code snippet for the function doing the other way round, ie. transforming regular datetimes into "yeast" datetimes ? thanks ! – jeremoquai Jul 14 '21 at 18:19
1

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

Victor
  • 46
  • 2