“We live in a world that has walls and those walls need to be guarded by men with guns” — Aaron Sorkin
One of the most important part of any code or program is how secure it is or how strong encryption algorithm , if we have not secured our passwords or authentication methods its always vulnerable and could have worse consequences.
So, what is Encryption?
Encryption is the method by which information is converted into secret code that hides the information’s true meaning.
Confidentiality encodes the message’s content.
Authentication verifies the origin of a message.
Integrity proves the contents of a message i.e. not been changed since its origin.
Non-repudiation prevents senders from denying they sent the encrypted message.
Although, there are many ways to encrypt and decrypt passwords, but AES (Advanced Encryption Standard) is one of the best and most trusted algorithms.
The Advanced Encryption Standard (AES), also known by as Rijndael I (named after its inventors), It has a fixed data block size of 16 bytes. Its keys can be 128, 192, or 256 bits long. AES is very fast and secure, and it is the de facto standard for symmetric encryption. AES allows us to choose a 128-bit, 192-bit or 256-bit key, making it exponentially stronger than the 56-bit key of DES (Data Encryption Standard).
Here are some of the major differences between AES and DES and why it makes it one of the best encryption methods:
I am not going into details about its history, you can find it in Wiki or AES dedicated sites, some of the links mentioned below:
You can get more details about AES Wiki here.
For complete details about Module AES read on here:
There are various modes to AES, some of them are:
ECB — Electronic Code Book (simplest encryption mode. Each of the plaintext blocks is directly encrypted into a ciphertext block, independent of any other block) ciphertext length (in bytes) must be a multiple of block_size.
CBC — Cipher Block Chaining (Each of the ciphertext blocks depends on the current and all previous plaintext blocks) ciphertext length (in bytes) must be a multiple of block_size.
CFB — Cipher Feedback (similar to CBC, but it transforms the underlying block cipher into a stream cipher) ciphertext length (in bytes) must be a multiple of segment_size/8.
OFB — Output Feedback (similar to CBC, but it transforms the underlying block cipher into a stream cipher.) ciphertext length (in bytes) must be a multiple of block_size.
Let’s try to understand how it can be used, as per below flowchart. We will encrypt the plain text with the help of AES algorithm and than again decrypt. We will use key as password which will help while decrypting into plain text.
Before we move to the code, let’s understand some of the key terms used in this method and which will help us to understand the code:
Padding — Creates extra space within an element. Padding is required by the AES to maintain a 16-octet (128-bit) block size, for e.g.
Key — is used for both encrypting and decrypting a block of messages
Block Size — AES uses a block size of sixteen octets (128 bits).
Hashing — (AES-hash is a secure hash function, meaning it takes an arbitrary bit string as input and returns a fixed length)
Now let’s see the entire code example how to encrypt and than decrypt:
Encryption is commonly used to protect data or passwords. Encryption is used to protect the information being relayed. Businesses are increasingly relying on encryption to protect their sensitive information and avoid any data breach. AES (Advanced Encryption Standard) is one of the most popular and versatile encryption method used widely across industries.
Thanks for reading, let me know if you like it and if you have any other way to solve such encryption challenges. Please share your feedback at email@example.com.