encipher method

void encipher(
  1. Uint32List leftRight,
  2. int arrayOffset
)

Blowfish encipher a single 64-bit block encoded as two 32-bit halves with the leftRight array that contains the two 32-bit half blocks and arrayOffset as the position in the array of the blocks.

Implementation

void encipher(Uint32List leftRight, int arrayOffset) {
  int i;
  int n;
  var l = leftRight[arrayOffset];
  var r = leftRight[arrayOffset + 1];
  l ^= P[0];
  for ((i = 0); i <= (blowfishNumRounds - 2);) {
    n = S[(l >> 24) & 0xff];
    n += S[0x100 | ((l >> 16) & 0xff)];
    n ^= S[0x200 | ((l >> 8) & 0xff)];
    n += S[0x300 | (l & 0xff)];
    r ^= n ^ P[++i];

    n = S[(r >> 24) & 0xff];
    n += S[0x100 | ((r >> 16) & 0xff)];
    n ^= S[0x200 | ((r >> 8) & 0xff)];
    n += S[0x300 | (r & 0xff)];
    l ^= n ^ P[++i];
  }
  leftRight[arrayOffset] = (r ^ P[blowfishNumRounds + 1]);
  leftRight[arrayOffset + 1] = l;
}