AES Encryption and Decryption Online

Along with AES Encryption and Decryption Online tool, we have provided other tools like URL Encode and Decode, Hashing. Also provide examples for aes 256 bit encryption.

This tool allows you to Encrypt/Decrypt any type of file and also allows you to download the same file.

Iframe Generator Tool License



Above tool is an AES Encryption and Decryption online free tool with other tools



What is Encryption?

Encryption is the process of converting information or message or data or file or image into a special format or secret code or unreadable format (ie hiding the actual information's meaning), so that only authorized persons can read and access it.

To unlock the message, both the sender and the recipient have to use a secret key or password.

This helps protect the confidentiality of digital data either stored on cloud servers or computer systems or mobile phones or transmitted over network like the internet.

Encrypted data is commonly referred to as ciphertext, while unencrypted data is called plaintext.

Encryption can help protect data you send, receive, and store, using a device. That can include text messages stored on your smartphone, running logs saved on your fitness watch, and banking information sent through your online account.



What is Decryption?

The process of converting encrypted information or message or data or file or image into a readable format or to it's original format is called decryption.


The science of encrypting and decrypting of information or data or message is called cryptography.

Currently, encryption is one of the most popular and effective data security methods used by most of the organisations around the world.


Advantages of encryption


1. Protects confidential data such as passwords and login id.

2. Provides confidentiality of private information.

3. Helps you to ensure that the document or file has not been altered.

4. Helpful for network communication and where a hacker can easily access unencrypted data.

5. It is an essential method as it helps you to securely protect data that you don't want anyone else to have access..



Difference between Encryption and Decryption


Encryption is a process of converting normal data into an unreadable form whereas Decryption is a method of converting the unreadable/coded data into its original form.

Encryption is done by the person who is sending the data to the destination, but the decryption is done at the person who is receiving the data.

The same algorithm with the same key is used for both the encryption-decryption processes.



Encryption Types:

There are several types of encryption algorithms, each developed with different needs and security needs in mind. They are divided into two types of encryption systems: symmetric encryption and asymmetric encryption also known as public-key encryption.

Symmetric encryption:

Symmetric encryption uses a single password to encrypt and decrypt data. It is faster than asymmetric encryption. But it has some drawbacks. For example a service performing encryption/decryption of a message with a key and your many clients consume that service, then you have to provide your key to your client also. It needs a high level of trust - so when you encrypt the date, then you have to provide the same key for decryption.


Symmetric Encryption

Following are some of the Symmetric encryption algorithms:

1. Data Encryption Standard (DES)

2. Triple DES (3DES)

3. Advanced Encryption Standard (AES)

4. TwoFish

5. International Data Encryption Algorithm (IDEA)

6. Blowfish (Drop-in replacement for DES or IDEA)

7. Rivest Cipher 4 (RC4)

8. Rivest Cipher 5 (RC5)

9. Rivest Cipher 6 (RC6)



Asymmetric encryption or Public key encryption:

Asymmetric encryption uses two keys for encryption and decryption — one key for encryption and another key for decryption. You are able to encrypt messages with a public key and decrypt messages with a private key. The public key is used only for encryption and cannot decrypt a message by a public key.


Asymmetric Encryption or Public key Encryption

Following are some of the Asymmetric encryption algorithms

1. RSA

2. Diffie–Hellman key exchange protocol

3. Digital Signature Standard (DSS)

4. Elliptic-curve cryptography

5. Elliptic Curve Digital Signature Algorithm (ECDSA)

6. Elliptic-curve Diffie–Hellman (ECDH)

7. Various password-authenticated key agreement techniques

8. Paillier cryptosystem

9. Cramer–Shoup cryptosystem

10. YAK authenticated key agreement protocol




AES Encryption and Decryption in java

Following is the sample program in java that performs AES encryption and decryption. Here, we are using AES with CBC mode with SHA-1 hashing to encrypt and decrypt a message as ECB mode is not semantically secure.

Note: This is just a basic encryption and decryption program.

Encryption and Decryption in java
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Arrays;
import java.util.Base64;
import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;

public class AES {

private static SecretKeySpec secretKey;
private static byte[] key;
private static String hashing = "SHA-1";
private static String mode = "AES/CBC/PKCS5Padding";

public static void setKey(String password) {
MessageDigest sha = null;
try {
key = password.getBytes("UTF-8");
sha = MessageDigest.getInstance(hashing);
key = sha.digest(key);
key = Arrays.copyOf(key, 16);
secretKey = new SecretKeySpec(key, "AES");
}
catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}

public static String encrypt(String message, String password) {
try {
setKey(password);
Cipher cipher = Cipher.getInstance(mode);
cipher.init(Cipher.ENCRYPT_MODE, secretKey);
return Base64.getEncoder().encodeToString(cipher.doFinal(message.getBytes("UTF-8")));
}
catch (Exception e) {
System.out.println("Error while encrypting message: " + e.toString());
}
return null;
}

public static String decrypt(String message, String password) {
try {
setKey(password);
Cipher cipher = Cipher.getInstance(mode);
cipher.init(Cipher.DECRYPT_MODE, secretKey);
return new String(cipher.doFinal(Base64.getDecoder().decode(message)));
}
catch (Exception e) {
System.out.println("Error while decrypting: " + e.toString());
}
return null;
}

public static void main(String[] args) {

String password = "1234567890";

String message = "My Credit Card number is 9999-9999-9999-9999 and PIN is 9999";
String encryptedMessage = AES.encrypt(message, password);
String decryptedMessage = AES.decrypt(encryptedMessage, password);

System.out.println("Message: " + message);
System.out.println("Password: " + password);
System.out.println("Encrypted Message: " + encryptedMessage);
System.out.println("Decrypted Message: " + decryptedMessage);

}
}




AES Encryption and Decryption in c#

Encryption and Decryption in c#
using System;
using System.IO;
using System.Text;
using System.Security.Cryptography;

class RijndaelExample {

string saltV = "EZHUTHELLAM";
string hashstring = "SHA1";
int iterations = 100;
string initVect = "@1B2c3D4e5F6g7H8";
int keysize = 256;

public static string encrypt(string passtext, string passPhrase) {
string functionReturnValue = null;
byte[] initVectorBytes = null;
byte[] saltValueBytes = null;
byte[] plainTextBytes = null;
byte[] keyBytes = null;
byte[] cipherTextBytes = null;

initVectorBytes = Encoding.ASCII.GetBytes(initVect);
saltValueBytes = Encoding.ASCII.GetBytes(saltV);

plainTextBytes = Encoding.UTF8.GetBytes(passtext);

PasswordDeriveBytes password = default(PasswordDeriveBytes);
password = new PasswordDeriveBytes(passPhrase, saltValueBytes, hashstring, iterations);
keyBytes = password.GetBytes(keysize/8);
RijndaelManaged symmetricKey = default(RijndaelManaged);
symmetricKey = new RijndaelManaged();

symmetricKey.Mode = CipherMode.CBC;
ICryptoTransform encryptor = default(ICryptoTransform);
encryptor = symmetricKey.CreateEncryptor(keyBytes, initVectorBytes);

MemoryStream memoryStream = default(MemoryStream);
memoryStream = new MemoryStream();

CryptoStream cryptoStream = default(CryptoStream);
cryptoStream = new CryptoStream(memoryStream, encryptor, CryptoStreamMode.Write);
cryptoStream.Write(plainTextBytes, 0, plainTextBytes.Length);

cryptoStream.FlushFinalBlock();
cipherTextBytes = memoryStream.ToArray();

memoryStream.Close();
cryptoStream.Close();

string cipherText = null;
cipherText = Convert.ToBase64String(cipherTextBytes);

functionReturnValue = cipherText;
return functionReturnValue;
}

public static string decrypt(string cipherText, string passPhrase) {
string functionReturnValue = null;

byte[] initVectorBytes = null;
initVectorBytes = Encoding.ASCII.GetBytes(initVector);

byte[] saltValueBytes = null;
saltValueBytes = Encoding.ASCII.GetBytes(saltV);

byte[] cipherTextBytes = null;
cipherTextBytes = Convert.FromBase64String(cipherText);

PasswordDeriveBytes password = default(PasswordDeriveBytes);
password = new PasswordDeriveBytes(passPhrase, saltValueBytes, hashstring, iterations);

byte[] keyBytes = null;
keyBytes = password.GetBytes(keySize / 8);

RijndaelManaged symmetricKey = default(RijndaelManaged);
symmetricKey = new RijndaelManaged();

symmetricKey.Mode = CipherMode.CBC;

ICryptoTransform decryptor = default(ICryptoTransform);
decryptor = symmetricKey.CreateDecryptor(keyBytes, initVectorBytes);

MemoryStream memoryStream = default(MemoryStream);
memoryStream = new MemoryStream(cipherTextBytes);

CryptoStream cryptoStream = default(CryptoStream);
cryptoStream = new CryptoStream(memoryStream, decryptor, CryptoStreamMode.Read);

byte[] plainTextBytes = null;
plainTextBytes = new byte[cipherTextBytes.Length + 1];

int decryptedByteCount = 0;
decryptedByteCount = cryptoStream.Read(plainTextBytes, 0, plainTextBytes.Length);

memoryStream.Close();
cryptoStream.Close();

string plainText = null;
plainText = Encoding.UTF8.GetString(plainTextBytes, 0, decryptedByteCount);

functionReturnValue = plainText;

return functionReturnValue;
}

public static void Main() {
string message = "My Credit Card number is 9999-9999-9999-9999 and PIN is 9999";
string password = "1234567890";
string encryptedMessage = encrypt(message, password);
string decryptedMessage = decrypt(encryptedstring, password);
Console.WriteLine("Original: {0}", message);
Console.WriteLine("Encrypted Message: {0}", encryptedMessage);
Console.WriteLine("Decrypted Message: {0}", decryptedMessage);
}

}




AES Encryption and Decryption in Python

Encryption and Decryption in Python
from Cryptodome.Cipher import AES as domeAES
from Crypto.Cipher import AES as cryptoAES
from Cryptodome.Random import get_random_bytes
from Crypto import Random
import base64
import hashlib

BLOCK_SIZE = AES.block_size

def trans(password):
key = password.encode()
__key__ = hashlib.sha256(key).digest()
return __key__

def encrypt(message, password):
BS = cryptoAES.block_size
pad = lambda s: s + (BS - len(s) % BS) * chr(BS - len(s) % BS)
raw = base64.b64encode(pad(message).encode('utf8'))
iv = get_random_bytes(cryptoAES.block_size)
cipher = cryptoAES.new(key = trans(password), mode = cryptoAES.MODE_CFB,iv = iv)
a = base64.b64encode(iv + cipher.encrypt(raw))
IV = Random.new().read(BLOCK_SIZE)
aes = domeAES.new(__key__, domeAES.MODE_CFB, IV)
encryptedMessage = base64.b64encode(IV + aes.encrypt(a))
return encryptedMessage

def decrypt(encryptedMessage, password):
passphrase = __key__
encrypted = base64.b64decode(encryptedMessage)
IV = encrypted[:BLOCK_SIZE]
aes = domeAES.new(passphrase, domeAES.MODE_CFB, IV)
enc = aes.decrypt(encrypted[BLOCK_SIZE:])
unpad = lambda s: s[:-ord(s[-1:])]
enc = base64.b64decode(enc)
iv = enc[:cryptoAES.block_size]
cipher = cryptoAES.new(trans(password), cryptoAES.MODE_CFB, iv)
decryptedMessage = unpad(base64.b64decode(cipher.decrypt(enc[cryptoAES.block_size:])).decode('utf8'))
return decryptedMessage


message = "My Credit Card number is 9999-9999-9999-9999 and PIN is 9999"
password = "1234567890"
encryptedMessage = encrypt(message, password)
decryptedMessage = decrypt(encryptedMessage, password)
print(message)
print(password)
print(encryptedMessage)
print(decryptedMessage)




AES Encryption and Decryption in PHP


Encryption and Decryption in PHP
<?php
// 32 byte binary blob
$aes256Key = hash("SHA256", $password, true);

// for good entropy (for MCRYPT_RAND)
srand((double) microtime() * 1000000);

// generate random iv
$iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_CBC), MCRYPT_RAND);

function encrypt($message, $password) {
global $iv;
return rtrim(base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $password, $message, MCRYPT_MODE_CBC, $iv)), "3");
}

function decrypt($encryptedMessage, $password) {
global $iv;
return rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $password, base64_decode($encryptedMessage), MCRYPT_MODE_CBC, $iv), "3");
}

$password = "1234567890";
$message = "My Credit Card number is 9999-9999-9999-9999 and PIN is 9999";

$encryptedMessage = encrypt($message, $aes256Key);
$decryptedMessage = decrypt($encryptedMessage, $aes256Key);

echo
"Encrypred Message : ".$encryptedMessage;
"Decrypred Message : ".$decryptedMessage;

php?>



AES Encryption and Decryption in Angular

It is very easy to implement the AES encryption and decryption in Angular 8 with the help of crypto-js.

Install a crypto.js file, by the below command.

npm install crypto-js --save

Optional: For better responsive UI, install bootstrap by the below command.

npm install bootstrap --save

Now, open “app.component.html” file and replace the existing code with the following code.

app.component.html
<h1 class="text-center">AES Encryption and Decryption with Angular</h1>
<br>
<div class="row">
<div class="col-sm-6">
<br>
<div class="form-group">
<label for="message">Plain Text</label>
<input id="message" type="text" class="form-control" placeholder="Enter the message" [(ngModel)]="message">
</div>
<div class="form-group">
<label for="password">Password</label>
<input id="password type="text" class="form-control" placeholder="Enter the password" [(ngModel)]="password">
</div>
<br/>
<div class="form-group">
<label for="encryptedMessage">Encrypted Message</label>
<textarea id="encryptedMessage" class="form-control" readonly rows="3">{{encryptedMessage}}</textarea>
</div>
<br/>
<div class="form-group">
<label for="decryptedMessage">Decrypted Message</label>
<textarea id="decryptedMessage" class="form-control" readonly rows="3">{{decryptedMessage}}</textarea>
</div>
<br>
<button type="button" class="btn btn-success float-right" (click)="encrypt()">Encrypt</button>
</div>
</div>


Now, open “app.component.ts” file and write the following code

app.component.ts
import { Component } from '@angular/core';
import * as CryptoJS from 'crypto-js';

@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {

constructor() {
}

public message: string;
public password: string;
public encryptedMessage: string;
public decryptedMessage: string;

encrypt() {
this.encryptedMessage = CryptoJS.AES.encrypt(this.message.trim(), this.password.trim()).toString();
this.decryptedMessage = CryptoJS.AES.decrypt(this.encryptedMessage, this.password.trim()).toString(CryptoJS.enc.Utf8);
}
}




Most Search For AES Encryption as

aes encryption | aes encryption online | aes decryption | aes decrypt online | advanced encryption standard | data encryption standard | aes encryption algorithm | aes key generation | aes 256 encryption | 256 bit encryption | aes 256 bit encryption | 128 bit encryption | aes encryption in java | encrypt and decrypt string in c# | python aes encryption | aes 256 | aes 128 | aes ecb | aes ctr | aes 256 encryption online | ontools aes decryption function | ontools aes encryption function | aes decryption function ontools | aes encryption function ontools | ontools crc function | ontools sha hash function |aes decryption function on tools | aes encryption function on tools | on tools aes decryption function | on tools aes encryption function | aes online | online aes encryption function ontools | online aes decryption function ontools | crc hash function ontools | ontools crc hash function |


License




# License

[The MIT License (MIT)](http://opensource.org/licenses/MIT)

Copyright (c) 2009-2013 Jeff Mott
Copyright (c) 2013-2021 Evan Vosberg

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.






No comments:

Post a Comment