3 ms·
Any alphanumeric string with a length that is a multiple of 4 is valid Base64 string. $ printf AAAA | base64 --decode | od -tx1 0000000 00 00 00 000
by susam 6y ago
Any alphanumeric string with a length that is a multiple of 4 is valid Base64 string.
$ printf AAAA | base64 --decode | od -tx1
0000000 00 00 00
0000003
$ printf AAAAAAAA | base64 --decode | od -tx1
0000000 00 00 00 00 00 00
0000006
$ printf AQEB | base64 --decode | od -tx1
0000000 01 01 01
0000003
$ printf AQID | base64 --decode | od -tx1
0000000 01 02 03
0000003
$ printf main | base64 --decode | od -tx1
0000000 99 a8 a7
0000003
$ printf scrabble | base64 --decode | od -tx1
0000000 b1 ca da 6d b9 5e
0000006
$ printf 12345678 | base64 --decode | od -tx1
0000000 d7 6d f8 e7 ae fc
0000006
Since '+' and '/' are also used as symbols in Base64 encoding (for binary 111110 and 111111, respectively), we also have:
$ printf 1+2+3+4+5/11 | base64 --decode | od -tx1
0000000 d7 ed be df ee 3e e7 fd 75
0000011
$ printf "\xd7\xed\xbe\xdf\xee\x3e\xe7\xfd\x75" | base64
1+2+3+4+5/11
- m463 6y ago$ echo "changeme" | base64 --decode | hexdump -C 00000000 72 16 a7 81 e9 9e |r.....| 00000006 $ echo "*lock*" | base64 --decode | hexdump -C base64: invalid input
- rootusrootus 6y agoThat's for the asterisks, not because length. $ echo "llockk" | base64 --decode | hexdump -C 00000000 96 5a 1c |.Z.| 00000003
- m463 6y agono! ha, I meant the old /etc/shadow trick of adding * lock * or * LCK * helps.
- billyhoffman 6y agoThe padding character =, used to pad the base64 string to be a multiple of 4, is technically optional as well since they can be inferred from the length, though different decoders can be more strict than others. So virtually all ascii words are valid base64 https://en.m.wikipedia.org/wiki/Base64 https://en.m.wikipedia.org/wiki/Base64 (I got burned by this a few months ago where Chrome can produce HAR files that have base64 encoded bodies without padding characters, and .NETs built in decoder expects them)