Flask Session Cookie Decoder/Encoder
Depencencies
Python 2 or Python 3 itsdangerous FlaskBlackArch Linux
# pacman -S flask-session-cookie-manager{3,2}Git
ArchLinux
Both python3 etn python2:
Other distros
Find your way with your package manager, use pip in a virtual environment or use pyenv.
Eg.
Usage
Use flask_session_cookie_manager3.py with Python 3 and flask_session_cookie_manager2.py with Python 2.
Encode
usage: flask_session_cookie_manager{2,3}.py encode [-h] -s <string> -t <string> optional arguments: -h, --help show this help message and exit -s <string>, --secret-key <string> Secret key -t <string>, --cookie-structure <string> Session cookie structureDecode
usage: flask_session_cookie_manager.py decode [-h] [-s <string>] -c <string> optional arguments: -h, --help show this help message and exit -s <string>, --secret-key <string> Secret key -c <string>, --cookie-value <string> Session cookie valueExamples
Encode
$ python{2,3} flask_session_cookie_manager{2,3}.py encode -s '.{y]tR&sp&[email protected]#[email protected]~yOF_51H(QV};K|ghT^d' -t '{"number":"326410031505","username":"admin"}' eyJudW1iZXIiOnsiIGIiOiJNekkyTkRFd01ETXhOVEExIn0sInVzZXJuYW1lIjp7IiBiIjoiWVdSdGFXND0ifX0.DE2iRA.ig5KSlnmsDH4uhDpmsFRPupB5VwNote: the session cookie structure must be a valid python dictionary
Decode
With secret key:
Without secret key (less pretty output):
$ python{2,3} flask_session_cookie_manager{2,3}.py decode -c 'eyJudW1iZXIiOnsiIGIiOiJNekkyTkRFd01ETXhOVEExIn0sInVzZXJuYW1lIjp7IiBiIjoiWVdSdGFXND0ifX0.DE2iRA.ig5KSlnmsDH4uhDpmsFRPupB5Vw' {"number":{" b":"MzI2NDEwMDMxNTA1"},"username":{" b":"YWRtaW4="}}
Original author : Wilson Sumanang
Fixes and improvements author : Alexandre ZANNI
Imported from saruberoz.github.io