---
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
import { addRoundKey, expandKeyFake, preprocessKey, preprocessPlaintextHex, shiftRows, subBytes } from './utils'
|
||||
|
||||
const plaintext = '0f1e2d3c4b5a69788796a5b4c3d2e1f0'
|
||||
|
||||
const key = '00000000000000000000000000000000'
|
||||
|
||||
const plaintextBlock = preprocessPlaintextHex(plaintext)[0]
|
||||
const keyBlock = preprocessKey(key)
|
||||
const roundKeys = expandKeyFake(keyBlock)
|
||||
|
||||
let state = plaintextBlock
|
||||
state = addRoundKey(state, roundKeys[0])
|
||||
state = subBytes(state)
|
||||
state = shiftRows(state)
|
||||
|
||||
console.log(`Plaintext: ${plaintext}`)
|
||||
console.log(`Key: ${key}`)
|
||||
console.log('State after applying the first two phases (SubBytes and ShiftRows) of the first round inside AES algorithm:')
|
||||
console.table(state)
|
||||
|
||||
console.log('Equivalent state in hexadecimal:')
|
||||
for (let rowIndex = 0; rowIndex < state.length; rowIndex++) {
|
||||
const row = state[rowIndex]
|
||||
for (let cellIndex = 0; cellIndex < row.length; cellIndex++) {
|
||||
const cell = row[cellIndex]
|
||||
state[rowIndex][cellIndex] = cell.toString(16).padStart(2, '0') as unknown as number
|
||||
}
|
||||
}
|
||||
console.table(state)
|
||||
Reference in New Issue
Block a user