We are here to understand the concept of encryption and decryption done for the various strings.
Encryption and Decryption
The concept of
encryption is the process of converting electronic
data into another equivalent form, called “
ciphertext” that cannot be easily understood by anybody except the authorized personnel. Whereas
decryption is the
reverse process of encryption.
- Data: The term data can be simply defined as the information translated into a form that is more convenient to process.
- Ciphertext: When the plaintext written by anyone is encrypted using some keys then the result is known as ciphertext.
The main and primary purpose of encryption is to protect the data confidentiality of digital data stored on a computer system or transmitted through the internet or other networks. It also takes care of the following security aspects:
- Authentication: Verification of the message can be done by its origin.
- Integrity: Ensures that the content of the message has not been changed during the transmission.
- Non-repudiation: The message sender cannot deny for the sent message.
There are various algorithms for encryption and decryption such as RSA algorithm, AES and so on that needs private and public keys. But here we will encrypt the string without using any algorithm.
First of all, we will explain the string encryption.
For encrypting the string we will consider various cases for varying characters in the given string. Just have a look at the code below to understand what is happening to encrypt the string using swa itch case.
Code example: Encryption
As we know, the string may contain lowercase letters, uppercase letters, numerals, special symbols and so on. In the following code, we did not write code for uppercase letters.
Various outputs for various strings
Output 1
Output 2
Now for
decryption we need to do just the reverse process. For demonstration, we are showing only code for the strings having uppercase letters and lowercase as decrypted text and the rest you can do yourself for practice.
Just look at the following code and outputs.
Code example: Decryption
Output 1Output 2
You can try your hand at the use of various symbols as the key for encryption or decryption. It all depends on the sender, how he/she encrypts the data.
Thank you, keep learning and sharing.