simple Python script to deal with Flask session cookie
Project description
Flask Session Cookie Decoder/Encoder
Original author : Wilson Sumanang
Fixes and improvements author : Alexandre ZANNI
Imported from saruberoz.github.io
Depencencies
- Python 2 or Python 3
- itsdangerous
- Flask
Installation
ArchLinux
Python 3
# pacman -S python
# pacman -S python-itsdangerous python-flask --asdep
Python 2
# pacman -S python2
# pacman -S python2-itsdangerous python2-flask --asdep
Other distros
Find your way with your package manager, use pip in a virtual environment or use pyenv.
Usage
Use flask_session_cookie_manager3.py
with Python 3 and flask_session_cookie_manager2.py
with Python 2.
usage: flask_session_cookie_manager{2,3}.py [-h] {encode,decode} ...
Flask Session Cookie Decoder/Encoder
positional arguments:
{encode,decode} sub-command help
encode encode
decode decode
optional arguments:
-h, --help show this help message and exit
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 structure
Decode
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 value
Examples
Encode
$ python{2,3} flask_session_cookie_manager{2,3}.py encode -s '.{y]tR&sp&77RdO~u3@XAh#TalD@Oh~yOF_51H(QV};K|ghT^d' -t '{"number":"326410031505","username":"admin"}'
eyJudW1iZXIiOnsiIGIiOiJNekkyTkRFd01ETXhOVEExIn0sInVzZXJuYW1lIjp7IiBiIjoiWVdSdGFXND0ifX0.DE2iRA.ig5KSlnmsDH4uhDpmsFRPupB5Vw
Note: the session cookie structure must be a valid python dictionary
Decode
With secret key:
$ python{2,3} flask_session_cookie_manager{2,3}.py decode -c 'eyJudW1iZXIiOnsiIGIiOiJNekkyTkRFd01ETXhOVEExIn0sInVzZXJuYW1lIjp7IiBiIjoiWVdSdGFXND0ifX0.DE2iRA.ig5KSlnmsDH4uhDpmsFRPupB5Vw' -s '.{y]tR&sp&77RdO~u3@XAh#TalD@Oh~yOF_51H(QV};K|ghT^d'
{u'username': 'admin', u'number': '326410031505'}
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="}}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for flask-session-cookie-manager-1.2.1.1.linux-x86_64.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0f31cb6d0c91bdd1f5db33d83e3b06faa4314c4a5455ac8b1538ce7f96248c5b |
|
MD5 | 441f647cd191a5e7574edcb1f51a3eeb |
|
BLAKE2b-256 | 546df3fd7413b2fb6a6b0d0783de7402f9cd1da1f3abc6fffc574050157d4642 |
Close
Hashes for flask_session_cookie_manager-1.2.1.1-py3.7.egg
Algorithm | Hash digest | |
---|---|---|
SHA256 | 85564b9c7190157c8da7ddf74402e74525df9ba9fe8a810ba8b92b4b3a6f14c8 |
|
MD5 | 3415cc46d98d84b4fdc158583e8fea2a |
|
BLAKE2b-256 | 38d1ddccab88ce547589b9118a706b21a7d0d722ea0d804aa1198b1a5951fc8b |