MCPcopy Index your code
hub / github.com/bcrypt-ruby/bcrypt-ruby / encipher

Method encipher

ext/jruby/bcrypt_jruby/BCrypt.java:487–508  ·  view source on GitHub ↗

Blowfish encipher a single 64-bit block encoded as two 32-bit halves @param lr an array containing the two 32-bit half blocks @param off the position in the array of the blocks

(int lr[], int off)

Source from the content-addressed store, hash-verified

485 * @param off the position in the array of the blocks
486 */
487 private final void encipher(int lr[], int off) {
488 int i, n, l = lr[off], r = lr[off + 1];
489
490 l ^= P[0];
491 for (i = 0; i <= BLOWFISH_NUM_ROUNDS - 2;) {
492 // Feistel substitution on left word
493 n = S[(l >> 24) & 0xff];
494 n += S[0x100 | ((l >> 16) & 0xff)];
495 n ^= S[0x200 | ((l >> 8) & 0xff)];
496 n += S[0x300 | (l & 0xff)];
497 r ^= n ^ P[++i];
498
499 // Feistel substitution on right word
500 n = S[(r >> 24) & 0xff];
501 n += S[0x100 | ((r >> 16) & 0xff)];
502 n ^= S[0x200 | ((r >> 8) & 0xff)];
503 n += S[0x300 | (r & 0xff)];
504 l ^= n ^ P[++i];
505 }
506 lr[off] = r ^ P[BLOWFISH_NUM_ROUNDS + 1];
507 lr[off + 1] = l;
508 }
509
510 /**
511 * Cycically extract a word of key material

Callers 3

keyMethod · 0.95
ekskeyMethod · 0.95
crypt_rawMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected