Remi Tricot-Le Breton | 5a8f02a | 2023-01-18 15:32:28 +0100 | [diff] [blame] | 1 | #!/usr/bin/python |
2 | |||||
3 | # JWT package can be installed via 'pip install pyjwt' command | ||||
4 | |||||
5 | import sys | ||||
6 | import jwt | ||||
7 | import json | ||||
8 | |||||
9 | if len(sys.argv) != 4: | ||||
10 | print(sys.argv[0],"<alg> <json_to_sign> <priv_key>") | ||||
11 | quit() | ||||
12 | |||||
13 | |||||
14 | alg=sys.argv[1] | ||||
15 | json_to_sign=sys.argv[2] | ||||
16 | priv_key_file=sys.argv[3] | ||||
17 | |||||
18 | with open(priv_key_file) as file: | ||||
19 | priv_key = file.read() | ||||
20 | |||||
21 | print(jwt.encode(json.loads(json_to_sign),priv_key,algorithm=alg)) | ||||
22 |