socket.iotimestampurl-parametersdata-formats

socket.io with strange timestamp format (?)


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


Solution

  • 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