Posts
Showing posts from September, 2019
Encryption And Decryption Using AES 128
- Get link
- X
- Other Apps
import java.util.Base64; import java.util.Scanner; import javax.crypto.Cipher; import javax.crypto.spec.IvParameterSpec; import javax.crypto.spec.SecretKeySpec; /** * * Program to Encrypt/Decrypt String Using AES 128 bit Encryption Algorithm */ public class EncryptDecryptString { private static final String encryptionKey = "SUMTOTALEXPENSE!"; private static final String characterEncoding = "UTF-8"; private static final String cipherTransformation = "AES/CBC/PKCS5PADDING"; private static final String aesEncryptionAlgorithem = "AES"; /** * * Method for Encrypt Plain String Data * @param plainText * * @return encryptedText */ public static String encrypt(String plainText) { String encryptedText = ""; try { Cipher cipher = Cipher.getInstance(cipherTransformation); byte[] key = encryptionKey.getBytes(characterEncoding); SecretKeySpec secre...