Package java.math

Examples of java.math.BigInteger.toByteArray()


                        writeVarLong(b.longValue());
                    }
                } else {
                    writeByte((byte) type);
                    writeVarInt(scale);
                    byte[] bytes = b.toByteArray();
                    writeVarInt(bytes.length);
                    write(bytes, 0, bytes.length);
                }
            }
            break;
View Full Code Here


                if (scale == 0) {
                    return 1 + getVarLongLen(b.longValue());
                }
                return 1 + getVarIntLen(scale) + getVarLongLen(b.longValue());
            }
            byte[] bytes = b.toByteArray();
            return 1 + getVarIntLen(scale) + getVarIntLen(bytes.length) + bytes.length;
        }
        case Value.TIME:
            if (SysProperties.STORE_LOCAL_TIME) {
                long nanos = ((ValueTime) v).getNanos();
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

    {
      byte[] kbytes = "jaas is the way".getBytes();
      SecretKeySpec key = new SecretKeySpec(kbytes, "Blowfish");
 
      BigInteger n = new BigInteger(secret, 16);
      byte[] encoding = n.toByteArray();
     
      Cipher cipher = Cipher.getInstance("Blowfish");
      cipher.init(Cipher.DECRYPT_MODE, key);
      byte[] decode = cipher.doFinal(encoding);
      return new String(decode);
View Full Code Here

      BigInteger r = new BigInteger(1, HexDump.hexStringToByteArray(rStr));
      BigInteger s = new BigInteger(1, HexDump.hexStringToByteArray(sStr));

      System.out.println("r: " + HexDump.byteArrayToHexString(r.toByteArray()));
      System.out.println(r.toString());
      System.out.println("s: " + HexDump.byteArrayToHexString(s.toByteArray()));
      System.out.println(s.toString());
      System.out.println(Base64.encode(convertBIGINTtoXMLDSIG(r, s)));
      System.out.println(Base64.encode(convertBIGINTtoASN1(r, s)));
   }
View Full Code Here

        i++;
        if (i == 0) return a;
        if (i == num + 1) return b;

        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);
        return padded;
View Full Code Here

        i++;
        if (i == 0) return a;
        if (i == num + 1) return b;
       
        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);
        return padded;
View Full Code Here

    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

        i++;
        if (i == 0) return a;
        if (i == num + 1) return b;
       
        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);
        return padded;
View Full Code Here

            sum = sum.multiply(BigInteger.valueOf(3));
            sum = sum.add(BigInteger.valueOf(intArray[i] + 1));
        }

        int size = (BigInteger.valueOf(3).pow(intArray.length).bitLength() + 7) / 8;
        byte[] arr = sum.toByteArray();

        if (arr.length < size)
        {
            // pad with leading zeros so arr.length==size
            byte[] arr2 = new byte[size];
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.