文档介绍:JAVAScript实现AES加密
1、
var password = 'L0ck it up saf3';
  var plaintext = 'pssst ... đon’t tell anyøne!';
  var ciphertext = (plaintext, password, 256);
  var origtext = (ciphertext, password, 256);
 
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  */
/*  AES implementation in JavaScript (c) Chris Veness 2005-2011                                   */
/*   - see #197                                    */
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  */
var Aes = {};  // Aes namespace
/**
 * AES Cipher function: encrypt 'input' state with Rijndael algorithm
 *   applies Nr rounds (10/12/14) using key schedule w for 'add round key' stage
 *
 * ***@param {Number[]} input 16-byte (128-bit) input state array
 * ***@param {Number[][]} w   Key schedule as 2D byte-array (Nr+1 x Nb bytes)
 * ***@returns {Number[]}     Encrypted output state array
 */
= function(input, w) {    // main Cipher function [§]
  var Nb = 4;               // block size (in words): no of columns in state (fixed at 4 for AES)
  var Nr = - 1; // no of rounds: 10/12/14 for 128/192/256-bit keys
  var state = [[],[],[],[]];  // initialise 4xNb byte-array 'state' with input [§]
  for (var i=0; i<4*Nb; i++) state[i%4][(i/4)] = input
[i];
  state = (state, w, 0, Nb);
  for (var round=1; round<Nr; round++) {
    state = (state, Nb);
    state = (state, Nb);
    state = (state, Nb);
    state = (state, w, round, Nb);
  }
  state = (state, Nb);
  state = (state, Nb);
  state = (state, w, Nr, Nb);
  var output = new Array(4*Nb);  // convert state to 1-d array before returning [§]
  for (var i=0; i<4*Nb; i++) output[i] = state[i%4][(i/4)];