4 ms·
Sanitized, well formed JSON is generally not horribly URL encoded. It's typically less overhead than base64. Also, for well formed JSON (not arbitrary JSON),
by Zamicol 3y ago
Sanitized, well formed JSON is generally not horribly URL encoded. It's typically less overhead than base64.
Also, for well formed JSON (not arbitrary JSON), it also works fine in HTTP headers. I think those two situations cover about 90% of use cases.
For example, here is a JSON payload URL encoded. It's not too bad, and much better than base64:
https://cyphr.me/coze#?input={%22pay%22:{%22msg%22:%22Hello%20Retr0id!%22,%22alg%22:%22ES256%22,%22iat%22:1701603747,%22tmb%22:%221KGZzsqiFAYE5uDO3CCh3PMl9pqwlG1RrI8i5gZY94c%22,%22typ%22:%22cyphr.me/msg/create%22},%22sig%22:%22vZEALUQShRlLYyhJoGmkxpQhhEeUPlzbIZqyTsUyPBMlJMIqGClgSs3uXTDiwumsMivFQKU8K4z4Ec7WlxYIew%22}&dontSignRevoke&updateIat&selectedAlg=ES256&verify https://cyphr.me/coze#?input={%22pay%22:{%22msg%22:%22Hello%...
The initial payload is 238 bytes, URL encoded that payload is 288 bytes, as base 64 it is 318 bytes. (Here's another tool just for that: https://convert.zamicol.com/#?inAlph=text&in=%257B%2522pay%2522%253A%257B%2522msg%2522%253A%2522Hello%2520Retr0id!%2522%252C%2522alg%2522%253A%2522ES256%2522%252C%2522iat%2522%253A1701603747%252C%2522tmb%2522%253A%25221KGZzsqiFAYE5uDO3CCh3PMl9pqwlG1RrI8i5gZY94c%2522%252C%2522typ%2522%253A%2522cyphr.me%252Fmsg%252Fcreate%2522%257D%252C%2522sig%2522%253A%2522vZEALUQShRlLYyhJoGmkxpQhhEeUPlzbIZqyTsUyPBMlJMIqGClgSs3uXTDiwumsMivFQKU8K4z4Ec7WlxYIew%2522%257D&outAlph=b64ut https://convert.zamicol.com/#?inAlph=text&in=%257B%2522pay%2...)
- Retr0id 3y agoI'd rather try to build systems that always work, rather than only working for well-formed inputs transmitted over well-behaved mediums.
- deleted 3y ago[deleted]
- Retr0id 3y agohttps://cyphr.me/coze#?input={%22pay%22:{%22msg%22:%22Hello,%20Zamicol.%20I%20believe%20you%20will%20find%20that%20this%20Coze%20message%20is%20also%20(supposedly)%20signed%20by%20your%20key!%20Coze%20could%20fix%20this%20issue%20with%20better%20UI,%20but%20I%20think%20this%20illustrates%20just%20how%20hard%20it%20is%20to%20canonicalize%20JSON.%20This%20wouldn't%20be%20possible%20in%20the%20first%20place%20if%20you%20were%20signing%20base64'd%20bytes.%22,%22msg%22:%22Hello%20Retr0id!%22,%22alg%22:%22ES256%22,%22iat%22:1701603747,%22tmb%22:%221KGZzsqiFAYE5uDO3CCh3PMl9pqwlG1RrI8i5gZY94c%22,%22typ%22:%22cyphr.me/msg/create%22},%22sig%22:%22vZEALUQShRlLYyhJoGmkxpQhhEeUPlzbIZqyTsUyPBMlJMIqGClgSs3uXTDiwumsMivFQKU8K4z4Ec7WlxYIew%22}&dontSignRevoke&updateIat&selectedAlg=ES256&verify https://cyphr.me/coze#?input={%22pay%22:{%22msg%22:%22Hello,...