By the end of the Article You will have a basic understanding of these topics:
Many misconceptions of encoding and encryption but the real meaning of encoding is Converting data from one format into another. The conversion is like changing the original data by inserting certain character sequences, numbers, special characters.
encoding is not security-based but it is used for communications and data storage.
Types of encoding
URLs can only be sent over the Internet using the ASCII character-set and there are instances when the URL contains special characters apart from ASCII characters, it needs to be encoded. URLs do not contain spaces and are replaced with a plus (+) sign or with %20.
The Browser (client-side) will encode the input according to the character set used in the web-page and the default character-set in HTML5 is UTF-8
Let’s take an example of converting “ABC” into Base64.
- Convert the characters in the string into decimal.
a = 97, b = 98 and c = 99.
2. Convert each of these decimal numbers into their equivalent 8-bit Binary form:
a = 0110 0001, b = 0110 0010 and c = 0110 0011
i.e. abc = 0110 0001 0110 0010 0110 0011
3. Separate them into groups of 6-bit each:
4. Convert each Binary into their equivalent Decimal form:
011000 = 24, 010110 = 22, 001001 = 9 and 100011 = 35
5. Using the Base64 table, convert each of these decimal numbers into their corresponding Base64 characters:
So, 24 = ‘Y’, 23 = ‘X’, 9 = ‘J’ and 35 = ‘j’.
Therefore, “abc” => “YXJj” in Base64.
Why do we need Encoding?
Encoding keeps your data safe since the files are not readable unless you have access to the algorithms that were used to encode it. … Since encoded data is smaller in size, you should be able to save space on your storage devices. This is ideal if you have large amounts of data that need to be archived
Internet is vulnerable in order to keep the confidential data safe encryption is used to keep the data safe. Encoding makes the data not human-readable and difficult to decode for an attacker.
Encryption makes use of Keys … It works by while sending the data it gets encrypted by the key and decrypted at the receiver end by using the key.
Encryption can be classified into two:
The Symmetric Key Cryptography approach is straightforward. Before sending out the data over to the receiver, the sender uses a Private key to cipher the data. This Private Key is known only to the Sender and the Receiver. So, once the receiver gets the encrypted data, he or she uses the sender’s same private key to decrypt it. Since the sender and the receiver uses the same key, this is known as “Symmetric Key” cryptography.
But the problem of using a symmetric key is, the key is already known to the receiver because of the single private key for both encrypt and decrypt. If there is an insecure connection there is a chance of interception and the key can be stolen.
To counter the problems of using the Symmetric Key Cryptography technique, the Asymmetric Key Cryptography technique is used. It is a relatively new technique compared to the previous one. As you can guess from the name itself, this technique involves two different keys. One key is used for encrypting the data, which is known as the Public Key and is known to virtually everyone on the internet. The other key is used for decrypting the data, which is known as the Private Key and is known only to the receiver and it must be kept discreet. Therefore the use of two distinct keys, makes the system more secure and it becomes way too difficult for an attacker to crack it.
Both public and private keys are relative to each other. So with the relative public key only it can be decrypted with the relative private Key.
If the public key is found by the attacker using that private key cannot be guessed.
Why do we need Encryption?
Encryption is a way of keeping your data safe and confidential as it is sent over the internet. Whenever you send personal information across the internet, be it passwords, credit card information, or personal contact details, encryption prevents attackers.
Hashing is converting the input data or string and produces a fixed-size output of enciphered text called a hash value.
Hashing works by allowing a one-way conversion from readable text to unreadable, fixed-length alphanumeric text. There is no practical way to convert the hash back to readable text.
In password hashing two users have the same password then there comes an ambiguity so salt comes into play for converting the password to hash and a unique character is added at the last.
Two of the most common hash algorithms are the MD5 (Message-Digest algorithm 5) and the SHA-1 (Secure Hash Algorithm).
Why do we need Hashing?
- Storing sensitive data that we don’t want to be recovered, such as passwords
- Looking up data quickly, such as a hash table
- Verifying the integrating of data.