Project Nayuki

AES cipher internals in Excel

AES-128 internals screenshot

Here I present the internal computations of the Advanced Encryption Standard cipher in a Microsoft Excel spreadsheet (also available for All 3 key lengths of AES are supported – 128, 192, and 256 bits. Shown are the bytes in each round (10/12/14 rounds) and in each step (SubBytes, ShiftRows, MixColumns, AddRoundKey, key schedule) of the cipher algorithm.

When you modify the input values, the intermediate steps and output will be recomputed automatically. The purpose of this spreadsheet is twofold – to demonstrate that Excel’s math functions are powerful enough to implement a real cipher, and to provide a debugging tool for anyone making their own AES implementation (because you can compare and see which intermediate step went wrong).

Only the two 4×4 squares with blue background are for user input; they are labelled “Plaintext” and “Key”. The other cells should not be modified. Keep in mind that AES is serialized in columns – bytes go down the leftmost column, then the next column to the right, and so on.

The calculations are implemented using ordinary spreadsheet functions, without using VBA or macros. The key mathematicals functions I used are VLOOKUP, BITXOR, DEC2HEX, and HEX2DEC. Curiously Excel doesn’t have BITXOR, so the OpenDocument version was easier to implement. There is a separate worksheet to store the long and unsightly lookup tables such as the S-box.


The AES cipher internals spreadsheet is available in multiple formats, all with the same content and formatting (except the ODS adds a sheet for decryption):

Microsoft Excel binary file format: aes-cipher-internals.xls

Works in most versions of Microsoft Excel.

Microsoft Office Open XML Workbook: aes-cipher-internals.xlsx

Preferred format for Microsoft Excel 2007 and above.

OpenDocument Spreadsheet: aes-cipher-internals.ods

Preferred format for the open-source office suites and LibreOffice.
Only this spreadsheet implements AES-128 decryption; the Excel ones don’t.

Compatibility notes

  • XLS file: In, the formulas should work properly but the style/formatting may be slightly incorrect. Tested working in 3.2.0, LibreOffice,

  • XLSX file: In, the formulas should work properly but the style/formatting may be slightly incorrect. Tested working in 3.2.0, LibreOffice Tested broken in LibreOffice

  • ODS file: Tested working in LibreOffice, Tested broken in 3.2.0, Microsoft Excel 2010; not expected to work in any version of Microsoft Excel.

More info