Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This question relates to Cryptography, more specifically, AES at 128-bits. Write

ID: 3810641 • Letter: T

Question

This question relates to Cryptography, more specifically, AES at 128-bits.

Write a java program that recieves an input key that is a length 16 hex string. The output will be an 11 row string array representation of all the round keys. The program must utilize an S-box table as well as an Rcon table. See attachment for sample input and output. Note that the first row of the output is the same as the input.

The output must be the 11 round keys, one in each row, a Sample Input 1: 15468617473206 D79204B75&E67204675; Sample Output 1: 5468617473206 D79204B756E67204675 E232FCF191 129188B 159E4E6D679A293 5608200 7C71AB18F76435569A03AF7FA D2600DE7157ABC686339B901C3031EFB A11202C9B468BEA1D75157AO!452495B B1293B3305418592D210D232C6429B69 BD3DC287B87C47156A6C9527AC2B0B4E CC96ED1674EAAA031E863F24B2A8316A 8B51EF21FABB4522B43D7A0656954B6C BFE2BF904559FAB2A16480B4F7F1CBD8 28 FDDEF86DA4244ACCC0A4FE3B3 16F26 86 53 79 62 09 22 27 542 76 63 46 26 73 272 32 9370 80 4C 36 163 41 76 63 78F8 81 86 50 02 81 1 1 7 64 46 77 793 76 38 p-82802916 2 6306-2391 426211DC A B B

Explanation / Answer

package com.AESCipher;
/** This program encrypts and decrypts strings using AES (Advanced Encryption Standard) 128 bit algorithm and using the UTF-8 charset.*/

import java.util.Base64;
import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;

public class Enc {
    private static byte[] key = {
        0x2d, 0x2a, 0x2d, 0x42, 0x55, 0x49, 0x4c, 0x44, 0x41, 0x43, 0x4f, 0x44, 0x45, 0x2d, 0x2a, 0x2d
    };

    public static String encryption(String plainText) {
        try {
               Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
               SecretKeySpec secretKey = new SecretKeySpec(key, "AES");
               cipher.init(Cipher.ENCRYPT_MODE, secretKey);
               byte[] cipherText = cipher.doFinal(plainText.getBytes("UTF8"));
               String encryptedString = new String(Base64.getEncoder().encode(cipherText),"UTF-8");
               return encryptedString;
              } catch (Exception e) {
                      e.printStackTrace();
              }
             return null;
    }
   
    public static String decryption(String encryptedText) {
        try {
               Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5PADDING");
               SecretKeySpec secretKey = new SecretKeySpec(key, "AES");
               cipher.init(Cipher.DECRYPT_MODE, secretKey);
               byte[] cipherText = Base64.getDecoder().decode(encryptedText.getBytes("UTF8"));
               String decryptedString = new String(cipher.doFinal(cipherText),"UTF-8");
               return decryptedString;
               } catch (Exception e) {
                      e.printStackTrace();
               }
               return null;
    }
   
    public static void main(String args[]) {
              String encrypted = encryption("AES-128 bit Encryption");
              String decrypted = decryption("tm+m/bhBMk+fc6a/2ScztLdY+PzGUhih1oNUiGKv97lfHAeiRclBKyU6Wi2elCri");
             System.out.println("Encrypted String : " + encrypted);
             System.out.println("Decrypted String : " + decrypted);
    }
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote