Python keeps text in a str and raw data in a bytes, and most encoding work is about crossing between the two. This set covers why the character count and the byte count can differ, why a hash needs bytes rather than text, how hex writes each byte as two characters, and when to reach for the URL-safe base64 alphabet. The task runs the whole sequence once and asks you to read what it printed.
Each one is marked as you go, and the explanation arrives straight after, which is
the part worth reading.
4 questions, marked as you go.
Tasks
These need your own device. Run the command in Termux, then paste what it printed.
The marking looks at what the output means, so spacing, version numbers and
ordering do not matter. If you have not installed anything yet, the
lesson covers the setup.
Encode, hash and base64 in one run
This counts the characters and the bytes in an accented word, shows two bytes as hex, hashes a message with SHA-256, and moves the same message through base64 and its URL-safe variant. Paste all five lines.
Run this in Termux
On your own device. Nothing on this page executes it. The command runs in
your terminal, and this box only reads what you paste back.
The first line is two numbers, the character count and then the byte count.
the character count and the byte count are both shown
the two bytes are written as hex
the SHA-256 digest is the real one for that message
the message was encoded as base64
the URL-safe alphabet was used for the three bytes of 255
the command actually ran
What a good answer looks like
Five lines. The first is 4 5, four characters but five bytes, because the accented e takes two bytes in UTF-8. The second is 4869, the hex of the two bytes of Hi. The third is the sixty four character SHA-256 digest of hello termux. The fourth is the base64 of that same message, which is aGVsbG8gdGVybXV4 with a b in front. The fifth is b____ for the three bytes of 255 in the URL-safe alphabet. If the first line is 4 4 you measured the same thing twice, and if the last line ends in four slashes you used the standard alphabet rather than the URL-safe one.
Marking your own work
Both halves of this are checked in your browser, with no server involved, so nothing
stops you from pasting output you did not run. The tasks are written so that the
easiest way to pass one is to actually do it and read the result, which is the whole
intention.