srakaceo.blogg.se

Base64 encoding explanation
Base64 encoding explanation












ABCD is encoded to QUJDRA= and there are appended two padding characters because QUJDRA (6 chars) nor QUJDRA= (7 chars) is divisible by 4. ABC is encoded to QUJD and there is no need to add a padding character because Base64 string is 4 characters long (that is, it's divisible by 4). AB is encoded to QUI= and there is appended only one padding character because QUI (3 chars) is not divisible by 4. Some examples: - A is encoded to QQ= and there are appended two padding characters because neither QQ (2 chars) nor QQ= (3 chars) is divisible by 4. So, if the output string is too small, it appends a padding character until the length is divisible by 4. Hi! By and large, the padding character ensures that the length of the Base64 string is a multiple of four. Given all of the above, a Base64 value can be defined using the following regular expression: ^+=$ All indices are listed in the Base64 table above. Only indices determine which characters will be used to encode the data, and only thanks to them you can “recover” the original data. Nevertheless, the heart of the algorithm contains only 64 characters, and for each of them there is a unique index. By and large, the padding character ensures that the length of Base64 value is a multiple of 4 bytes and it is always appended at the end of the output.

base64 encoding explanation

That is, the equal sign does not own an index and is not involved in the encoding of data. In addition to these characters, the equal sign ( =) is used for padding.

base64 encoding explanation

Guru A virtual teacher who reveals to you the great secrets of Base64














Base64 encoding explanation