4 ms·
Weird choice to pick 8 bytes then cut off the padding, you're effectively not using 2 bits in your last character that way. Might as well make it 12 characters
by contravariant 6y ago
Weird choice to pick 8 bytes then cut off the padding, you're effectively not using 2 bits in your last character that way.
Might as well make it 12 characters instead of 11 and encode a full 9 bytes.
Although seems like Youtube's done the same thing.
- irq-1 6y agothe '=' isn't url safe.
- nostoc 6y agoThat's not the point. encoding 9 bytes doesn't give any '=', because 3 bytes encode to 4 b64 characters.
- ignoramous 6y agoAFAIK: '=' is URI (path) safe [0] '=' is not query-param safe [1] Ex: [0] https://golang.org/pkg/net/url/#PathEscape https://golang.org/pkg/net/url/#PathEscape [1] https://golang.org/pkg/net/url/#QueryEscape https://golang.org/pkg/net/url/#QueryEscape
- gregmac 6y agoWell you do save a byte in the actual key. I guess if you really want to keep it to 11 bytes, it would be better to generate 9 bytes of random data, base64 it (which uses the full 12 characters, with no padding), and truncate to 11. You're throwing away 6 bits of random, but now all 88 bits in your 11-character key are useful (instead of only 86 bits).