Skip to content

Instantly share code, notes, and snippets.

@pyar6329
Created June 3, 2021 12:05
Show Gist options
  • Save pyar6329/67cd1ee581eddc17af09dfac703a0736 to your computer and use it in GitHub Desktop.
Save pyar6329/67cd1ee581eddc17af09dfac703a0736 to your computer and use it in GitHub Desktop.
base64 URL encoding vs URL encoding
import json
import random
style = ["Structured", "Plain"]
max_size = 320
dic = {i: style[random.randint(0, 1)] for i in range(max_size)}
json_dic = json.dumps(dic,ensure_ascii=False)
print(json_dic)
#!/bin/bash
python main.py | jq -c -r > main.json
cat main.json | base64 -w 0 | tr '/+' '_-' | tr -d '=' > base64url.txt
cat main.json | nkf -WwMQ | sed 's/=$//g' | tr = % | tr -d '\n' > url_encode.txt
wc -m *.txt
@pyar6329
Copy link
Author

pyar6329 commented Jun 3, 2021

$ ./main.sh
 6870 base64url.txt
 8993 url_encode.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment