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 LibreOffice / Apache OpenOffice). AES encryption for all 3 key lengths (128, 192, 256 bits) are supported, and decryption for 128 bits is also supported. The spreadsheet shows the bytes in each round (10/12/14 rounds) and 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 older versions of 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:

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

Works in basically all 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 LibreOffice and Apache OpenOffice.

Compatibility notes

More info