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

In Java PLEASE I. Symmetric Cryptosystem In this programming Assignment, student

ID: 3757262 • Letter: I

Question

In Java PLEASE

I. Symmetric Cryptosystem In this programming Assignment, students are asked to implement a toy symmetric cryptosystem based on the following method. a. Keys are 16-bit randomly generated values b. Messages are randomly generated strings with an even number of characters Valid characters are upper and lower-case letters) C. The encryption of a message M of length n (in bytes) is given by Where the key K is represented n/2 times and "ll means String Concatenation Operator d. The decryption algorithm for a ciphertext C is the same as the encryption algorithm Students need to implement a brutal force decryption attack for this cryptosystem and test it on randomly generated English character message. Requirement: 1. You can use Java or Python programming language to finish this assignment and follow the given Structure. Your work is expected to be runnable. Any program has error or exception will receive 0 as grade 2. 3. A copied program will receive 0 as grade.

Explanation / Answer

function strtoarr (str) {

return new TextEncoder().encode(str)

}

function arrtostr (arr) {

return new TextDecoder().decode(arr)

}

function salt() {

var vector = new Uint8Array(16)

crypto.getRandomValues(vector)

return Array.from(vector)

}

function encrypt (txt, pas, slt, fnc) {

var vector = new Uint8Array(slt)

crypto.subtle.digest({name: 'SHA-256'}, strtoarr(pas)).then((res) => {

    crypto.subtle.importKey('raw', res, {name: 'AES-CBC'}, false, ['encrypt', 'decrypt']).then((key) => {

      crypto.subtle.encrypt({name: 'AES-CBC', iv: vector}, key, strtoarr(txt)).then((res) => {

        fnc(Array.from(new Uint8Array(res)), Array.from(vector))

      })

    })

})

}

function decrypt (cyp, pas, slt, fnc) {

var data = new Uint8Array(cyp)

var vector = new Uint8Array(slt)

crypto.subtle.digest({name: 'SHA-256'}, strtoarr(pas)).then((res) => {

    crypto.subtle.importKey('raw', res, {name: 'AES-CBC'}, false, ['encrypt', 'decrypt']).then((key) => {

      crypto.subtle.decrypt({name: 'AES-CBC', iv: vector}, key, data).then((res) => {

        fnc(arrtostr(res))

      }, () => {

        fnc(null)

      })

    })

})

}

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