Today I Learned

3

Days Learned

Computers multiply big numbers fast by reducing multiplication

COPY LINK

The Karatsuba algorithm reduces the number of multiplications needed for two n-digit numbers that require k multiplication steps by substituting them with k-1 multiplications plus an addition instead of k multiplications, as multiplication is asymptotically more expensive than addition.


.bss section stores unintialized varibales

COPY LINK

The .data section in ELF binaries is used for holding initialized global or static variables. The local variables are stored in the stack. All the uninitialized global or static variables are stored in the .bss section and occupy no space in the binary, as they are zeroed at runtime.


Base64 encoding

COPY LINK

Base64 encoding allows us to encode any bytes to “safe” bytes, bytes which are known to be safe to send without getting corrupted.

Example of “unsafe” bytes would be control characters.

To send text with Base64 encoding we first encode the text to say UTF-8, after that we group the binary into chunks of 3 bytes, we further divide the chunks into four 6-bit groups. Now each 6-bit group can represent values between 0 and 63, these values are then mapped to the corresponding Base64 character.

What if the chunks are not of 3 bytes?

For 1 extra byte we have space left for 2 bytes, we pad the econding with ==

For 2 extra byte we have space left for 1 byte, we pad the encoding with =

The reciever will have to reverse the process to recover the original text.