Package java.math

Examples of java.math.BigInteger.toByteArray()


        byte[] output = key.getModulus().toByteArray();
        Arrays.fill(output, (byte)0);
        System.arraycopy(m1m2Crypt.toByteArray(), 0, output, output.length
                - m1m2Crypt.toByteArray().length,
                m1m2Crypt.toByteArray().length);

        return output;
    }

    /**
 
View Full Code Here


                                      IllegalBlockSizeException
   {
      SecretKeySpec key = new SecretKeySpec(internalKey, "Blowfish");

      BigInteger n = new BigInteger((String)secret, 16);
      byte[] encoding = n.toByteArray();

      // JBAS-3457: fix leading zeros
      if (encoding.length % 8 != 0)
      {
         int length = encoding.length;
View Full Code Here

    private static byte[] incrementID(byte[] key) {

        BigInteger id = new BigInteger(key);
        id = id.add(BigInteger.valueOf(1));
        return id.toByteArray();
    }

    /**
     * Holds the class format key for a class, maintains a reference to the
     * ObjectStreamClass.  Other fields can be added when we need to store more
View Full Code Here

        int scale = val.scale();
        BigInteger unscaledVal = val.unscaledValue();
       
        /* Store the scale. */
        writePackedInt(scale);
        byte[] a = unscaledVal.toByteArray();
        int len = a.length;
       
        /* Store the length of the following bytes. */
        writePackedInt(len);
       
View Full Code Here

     */
    public static int getBigDecimalMaxByteLength(BigDecimal val) {

        BigInteger unscaledVal = val.unscaledValue();
        return PackedInteger.MAX_LENGTH * 2 +
               unscaledVal.toByteArray().length;
    }
   
    /**
     * Writes a sorted {@code BigDecimal}.
     *
 
View Full Code Here

        }

        if (!kekOnly) {
            // public key (just Y)
            BigInteger y = publicKey.getY();
            byte[] yBytes = y.toByteArray();
            String yHex = StringUtil.toHexString(yBytes);
            buf.append("======== Begin Public Key (Y @ ").append(yBytes.length).append(" / ").append(yHex.length()).append(") ========\n");
            buf.append(yHex).append("\n");
            buf.append("======== End Public Key ========\n\n");
View Full Code Here

            buf.append(yHex).append("\n");
            buf.append("======== End Public Key ========\n\n");

            // private key (just X)
            BigInteger x = privateKey.getX();
            byte[] xBytes = x.toByteArray();
            String xHex = StringUtil.toHexString(xBytes);
            buf.append("======== Begin Private Key (X @ ").append(xBytes.length).append(" / ").append(xHex.length()).append(") ========\n");
            buf.append(xHex).append("\n");
            buf.append("======== End Private Key ========\n\n");
View Full Code Here

    byte [][] result = new byte[num+2][];
    result[0] = a;

    for (int i = 1; i <= num; i++) {
      BigInteger curBI = startBI.add(intervalBI.multiply(BigInteger.valueOf(i)));
      byte [] padded = curBI.toByteArray();
      if (padded[1] == 0)
        padded = tail(padded,padded.length-2);
      else
        padded = tail(padded,padded.length-1);
      result[i] = padded;
View Full Code Here

      if (object == null) {
        output.writeVarInt(NULL, true);
        return;
      }
      BigInteger value = (BigInteger)object;
      byte[] bytes = value.toByteArray();
      output.writeVarInt(bytes.length + 1, true);
      output.writeBytes(bytes);
    }

    public BigInteger read (Kryo kryo, Input input, Class<BigInteger> type) {
View Full Code Here

    public void bigIntegerObjectShouldReturnBigIntegerByteBuffer() {
        ExtensibleTypeInferringSerializer.addSerializer(BigInteger.class, BigIntegerSerializer.get());

        BigInteger value = BigInteger.valueOf(0x0807060504030201L);

        byte[] array = value.toByteArray();
        ByteBuffer expectedBuffer = ByteBuffer.wrap(array);

        ByteBuffer buffer = extendedTypeInferringSerializer.toByteBuffer(value);

        assertEquals(expectedBuffer, buffer);
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.