Package org.kocakosm.pitaya.util

Examples of org.kocakosm.pitaya.util.ByteBuffer.toByteArray()


    buf.append(b);
    b = new byte[20];
    int len = in.read(b, 0, 15);
    buf.append(b, 0, len);
    assertEquals(16, in.getCount());
    assertArrayEquals(DATA, buf.toByteArray());
  }

  @Test
  public void testCount() throws IOException
  {
View Full Code Here


          f[k] ^= u[k];
        }
      }
      t.append(f);
    }
    return t.toByteArray(0, dkLen);
  }

  @Override
  public String toString()
  {
View Full Code Here

    ByteBuffer buf = new ByteBuffer(HASH_LENGTH + SALT_LENGTH + 3);
    buf.append(scrypt.deriveKey(UTF8.encode(password), salt));
    buf.append(salt);
    buf.append((byte) Math.round(Math.log(n) / Math.log(2)));
    buf.append((byte) r, (byte) p);
    return buf.toByteArray();
  }

  private static byte[] salt()
  {
    byte[] salt = new byte[SALT_LENGTH];
View Full Code Here

  {
    ByteBuffer buf = new ByteBuffer(bytes.length);
    while (buf.size() < bytes.length) {
      buf.append(src);
    }
    System.arraycopy(buf.toByteArray(), 0, bytes, 0, bytes.length);
  }
}
View Full Code Here

    byte[] u = new byte[0];
    for (int i = 1; i <= n; i++) {
      u = mac.update(u).update(info).mac((byte) i);
      t.append(u);
    }
    return t.toByteArray(0, dkLen);
  }
}
View Full Code Here

    ByteBuffer buffer = new ByteBuffer(p * 128 * r);
    for (int i = 0; i < p; i++) {
      buffer.append(roMix(slice(b, i * 128 * r, 128 * r)));
    }
    pbkdf2 = KDFs.pbkdf2(Algorithm.HMAC_SHA256, 1, dkLen);
    return pbkdf2.deriveKey(secret, buffer.toByteArray());
  }

  @Override
  public String toString()
  {
View Full Code Here

      x = blockMix(x);
    }
    int offset = (2 * r - 1) * 64;
    for (int i = 0; i < n; i++) {
      int j = LittleEndian.decodeInt(x, offset) & (n - 1);
      x = blockMix(xor(x, v.toByteArray(j * len, len)));
    }
    return x;
  }

  private byte[] blockMix(byte[] in)
View Full Code Here

    ByteBuffer buffer = new ByteBuffer(128 * r);
    for (int i = 0; i < 2 * r; i++) {
      x = salsa20(xor(x, slice(in, i * 64, 64)), 8);
      buffer.append(x);
    }
    byte[] y = buffer.toByteArray();
    byte[] b = new byte[in.length];
    for (int i = 0; i < r; i++) {
      System.arraycopy(y, (i * 2) * 64, b, i * 64, 64);
    }
    for (int i = 0; i < r; i++) {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.