Category: Short tutorials

  • How Does Base64 Encoding Work?

    Some things you might have heard being thrown around in the cryptography space are encoding methods. Such encoding methods are normally used to turn binary data into text, typically so it can be used to transmit data over communication methods that do not allow raw binary data to be transmitted.

    How does binary turn into Base64?

    First, let’s say that we want to encode an image. We start by reading all the bits in the image, which, for this example, will result in a binary stream of 010010101101001000111111. It is important to note that most images are a lot larger than this and will contain hundreds of thousands of bits.

    The encoder will first break the binary stream up into their own chunks, each containing six bits. We can do this to our example and get 010010 101101 001000 111111.

    Then, we turn our binary chunks into decimals.

    To do this, working right to left, we multiply each bit by 2 to the power of p, where p starts from zero and increments by one for every bit in the chunk.

    For example, we can calculate 010010 by performing the expression (0 * 20) + (1 * 21) + (0 * 22) + (0 * 23) + (1 * 24) + (0 * 25). We can strip away any parts that multiply by zero, since those will always be zero. The simplified equation is (1 * 21) + (1 * 24) = 2 + 16 = 18. Therefore, 010010 is equivalent to the decimal 18.

    Turning every single six-bit binary chunk into a decimal using the process shown above constitutes the numbers (in left-to-right order) 18, 45, 8, and 63.

    After that, we can simply cross reference the numbers with whatever alphabet we should use. For example, the six-bit chunk 010010 turns into the decimal 18, which corresponds to S on the Base64 standard alphabet. Therefore, 010010 101101 001000 111111 turns into StI/.

    How does binary turn into Base64?: fixing the padding

    If the binary string is a multiple of 3, everything fits perfectly. However, if it is not, then we need to add padding to the encoded string until the string’s bit count becomes a multiple of 3.

    Let’s take 010010 101101 001000 111111 01 as an example. It is 26 bits long and all full six-bit chunks encode to StI/. However, this is leaving out the two bits at the end.

    To pad this, we will keep adding zeroes to the end of the string until it can become a full chunk. Thus, the final chunk, 01, becomes 010000, which corresponds to Q in the Base64 alphabet. Then, we add one padding character (typically an =) for every two bits we had to add for the string to only be made of full chunks. We add two padding characters because four (the number of bits we had to add) divided by two is two.

    Thus, you would think that the padded string would be StI/Q==, right? Well, no, because that extra character adds another six bits, meaning that there are still two bits at the end. We can only stay in such a loop two times, so we need to add more zeroes. That means that the final letter is 000000, which is A.

    So, the final result is StI/QA==.

    How does Base64 turn into binary?

    Base64 decoding is just like base64 encoding, but in reverse. First, we turn every single non-padding character into its respective index on the alphabet, then we turn every single number into its binary equivalent.

    For example, let’s take our string StI/QA==. We first take every single non-padding character and turn it into a string of numbers that represents their indexes on the alphabet.

    This turns our Base64-encoded string into a string of numbers, specifically 18 45 37 62 16 0 = =, since we don’t turn the padding into a number

    The Standard Base64 Alphabet

    0: A7: H14: O21: V28: c35: j42: q49: x56: 5
    1: B8: I15: P22: W29: d36: k43: r50: y57: 6
    2: C9: J16: Q23: X30: e37: l44: s51: z58: 7
    3: D10: K17: R24: Y31: f38: m45: t52: 159: 8
    4: E11: L18: S25: Z32: g39: n46: u53: 260: 9
    5: F12: M19: T26: a33: h40: o47: v54: 361: +
    6: G13: N20: U27: b34: i41: p48: w55: 462: /
    Padding: =
  • How to Create Bash Aliases in Linux, and How They Work

    If you are like me, you will often find yourself typing long, bulky, and hard-to-remember commands in the Linux terminal, and if not, I will almost always find myself searching the bash history for a long command I typed earlier. If you are also like me, this is where bash aliases come in handy. Bash aliases are like shortcuts, short, quick replacements for long, bulky commands. For example, you can use rmopwrt instead of opkg remove --force-remove --force-removal-of-dependent-packages ppp ppp-mod-pppoe odhcpd-ipv6only dnsmasq hostapd-common luci luci-ssl-openssl luci-base lua luci-app-firewall luci-lib-ip luci-lib-jsonc luci-lib-nixio luci-proto-ipv6 luci-proto-ppp luci-theme-bootstrap uhttpd uhttpd-mod-ubus. In this post, I will show you how to create bash aliases in Linux, so you can save time on the command line, and be more productive.

    Creating Bash Aliases

    Creating bash aliases is very easy and straightforward. The basic command is as follows:

    BASH SHELL
    
    alias whatever_you_want_your_alias_to_be_called="command_to_run"

    However, like always, make sure not to use spaces in the name, else Linux will think it is a command argument, and the alias command does not take any. When you create an alias, you type “alias”, followed by your alias name, an equal sign without spaces, and then, without spaces, in quotes, what command the alias should run. In the case above, running whatever_you_want_your_alias_to_be_called will do the same thing as running command_to_run.

    Let us try another example.

    BASH SHELL
    
    alias myip="hostname -I"

    When you run myip, you will get the same output as running hostname -I.

    Done!

  • The full guide to cryptocurrency: Part 2 – Alternatives and issues

    LightLightDarkDark

    If you remembered last time, we talked about how crypto works. This time, it will be a short tutorial on all the things I did not cover last time.

    Alternatives

    Bitcoin is just one of the 4,000 cryptocurrencies that there are today. There are many alternatives to Bitcoin. Like Etherium can process transactions faster than bitcoin. Litecoin uses a more modern algorithm. Ravencoin has better mining abilities. One token is the most expensive. Its lowest as of this week was $1,000,000.

    Sign up for our newsletter!

    Issue #1: Nobody knows how much it should be worth

    Take bitcoin for example. Tesla and Microsoft announced that they were going to be accepting it, it goes way up. They announced that they are no longer accepting it, it goes way down.

    Issue #2: It has a dark side

    Many people, hackers, and ransomware will make you pay in Bitcoin because it’s hard to track.

    Issue #3: Not evreybody accepts it

    The only popular companies that accept it are:

    • Newegg (Kind of)
    • Microsoft

    Issue #4: It’s banned in some countries

    For example, China

    Bye

    I know this one was short and boring, but my next one is going to be how to mine it.

  • Downloading ASUS Aura Sync

    LightLightDarkDark

    You can download it from the ASUS Website.

    Sign up for our newsletter!

    I suggest this video: