/** * Write an integer at the current position. * The current position is incremented. * * @param x the value */ public void writeInt(int x) { Bits.writeInt(data, pos, x); pos += 4; }
/** * Update an integer at the given position. * The current position is not change. * * @param pos the position * @param x the value */ public void setInt(int pos, int x) { Bits.writeInt(data, pos, x); }
/** * Writes a long value to the byte array at the given position in big-endian * order. * * @param buff * the byte array * @param pos * the position * @param x * the value to write */ public static void writeLong(byte[] buff, int pos, long x) { writeInt(buff, pos, (int) (x >> 32)); writeInt(buff, pos + 4, (int) x); }
private void encryptBlock(byte[] in, byte[] out, int off) { int x0 = Bits.readInt(in, off); int x1 = Bits.readInt(in, off + 4); int x2 = Bits.readInt(in, off + 8); int x3 = Bits.readInt(in, off + 12); int k = key; x0 = Integer.rotateLeft(x0 ^ k, x1); x2 = Integer.rotateLeft(x2 ^ k, x1); x1 = Integer.rotateLeft(x1 ^ k, x0); x3 = Integer.rotateLeft(x3 ^ k, x0); Bits.writeInt(out, off, x0); Bits.writeInt(out, off + 4, x1); Bits.writeInt(out, off + 8, x2); Bits.writeInt(out, off + 12, x3); }
if (i == 0) { System.arraycopy(salt, 0, message, 0, salt.length); Bits.writeInt(message, salt.length, k); len = salt.length + 4; } else {
private void decryptBlock(byte[] in, byte[] out, int off) { int x0 = Bits.readInt(in, off); int x1 = Bits.readInt(in, off + 4); int x2 = Bits.readInt(in, off + 8); int x3 = Bits.readInt(in, off + 12); int k = key; x1 = Integer.rotateRight(x1, x0) ^ k; x3 = Integer.rotateRight(x3, x0) ^ k; x0 = Integer.rotateRight(x0, x1) ^ k; x2 = Integer.rotateRight(x2, x1) ^ k; Bits.writeInt(out, off, x0); Bits.writeInt(out, off + 4, x1); Bits.writeInt(out, off + 8, x2); Bits.writeInt(out, off + 12, x3); }