Package java.math

Examples of java.math.BigInteger.toByteArray()


     */
    static Object tileKey(PlanarImage owner, int tileX, int tileY) {
        long idx = tileY * (long)owner.getNumXTiles() + tileX;

        BigInteger imageID = (BigInteger)owner.getImageID();
        byte[] buf = imageID.toByteArray();
        int length = buf.length;
        byte[] buf1 = new byte[length + 8];
        System.arraycopy(buf, 0, buf1, 0, length);
        for (int i = 7, j = 0; i >= 0; i--, j += 8)
           buf1[length++] = (byte)(idx >> j);
View Full Code Here


     */
    static Object tileKey(PlanarImage owner, int tileX, int tileY) {
        long idx = tileY * (long)owner.getNumXTiles() + tileX;

        BigInteger imageID = (BigInteger)owner.getImageID();
        byte[] buf = imageID.toByteArray();
        int length = buf.length;
        byte[] buf1 = new byte[length + 8];
        System.arraycopy(buf, 0, buf1, 0, length);
        for (int i = 7, j = 0; i >= 0; i--, j += 8)
           buf1[length++] = (byte)(idx >> j);
View Full Code Here

            imageID = (BigInteger)((PlanarImage)owner).getImageID();
        else if (owner instanceof SerializableRenderedImage)
            imageID = (BigInteger)((SerializableRenderedImage)owner).getImageID();

        if (imageID != null) {
            byte[] buf = imageID.toByteArray();
            int length = buf.length;
            byte[] buf1 = new byte[length + 8];
            System.arraycopy(buf, 0, buf1, 0, length);
            for (int i = 7, j = 0; i >= 0; i--, j += 8)
                buf1[length++] = (byte)(idx >> j);
View Full Code Here

        while ( ( line = bufReader.readLine() ) != null )
        {
            String[] nodeTokenPair = line.split(" ");
            /* Add the node and the token pair into the header of this message. */
            BigInteger nodeToken = new BigInteger(nodeTokenPair[1]);
            tokenUpdateMessage.addHeader(nodeTokenPair[0], nodeToken.toByteArray());
        }
       
        System.out.println("Sending a token update message to " + target);
        MessagingService.getMessagingInstance().sendOneWay(tokenUpdateMessage, target);
        Thread.sleep(TokenUpdater.waitTime_);
View Full Code Here

     */
    @Deprecated
    public static String decryptLegacy (String str, byte[] key) {
        BigInteger in = new BigInteger(str, 16).xor(new BigInteger(1, key));
        try {
            return new String(in.toByteArray(), "utf8");
        } catch (UnsupportedEncodingException e) {
            return "";
        } catch (NumberFormatException e) {
            Logger.logError("Error occurred during legacy decryption");
            return "";
View Full Code Here

        @Override
        public ByteBuffer serialize(BigDecimal value) {
            BigInteger bi = value.unscaledValue();
            int scale = value.scale();
            byte[] bibytes = bi.toByteArray();

            ByteBuffer bytes = ByteBuffer.allocate(4 + bibytes.length);
            bytes.putInt(scale);
            bytes.put(bibytes);
            bytes.rewind();
View Full Code Here

        final int signum = v.signum();
        BigInteger val = v;
        if (signum < 0) {
            val = val.negate();
        }
        final byte[] magnitude = val.toByteArray();
        final int n = magnitude.length;
        // Reverse the array to make it little endian.
        for (int i = 0, j = n; i < j--; i++) {
            // Swap [i] with [j]
            final byte b = magnitude[i];
View Full Code Here

          val >>= 8;
        }
        } else { // Larger integer case
        BigInteger big_int = ei.bigintValue();

        byte[] bytes = big_int.toByteArray();
        int src_pos = bytes.length;
        while (--src_pos >= 0 && nBytes-- > 0) {
          data[pos] = bytes[src_pos];
          pos += delta;
        }
View Full Code Here

    final String channelName = channel.name;
    final Delivery channelDelivery = channel.delivery;
    if (logger.isLoggable(Level.FINEST)) {
        logger.log(
      Level.FINEST, "sending refresh, channel:{0}",
      HexDumper.toHexString(channelRefId.toByteArray()));
    }
    for (final long nodeId : channel.servers) {
        channelService.addChannelTask(
          channelRefId,
      new IoRunnable() {
View Full Code Here

    {
        if (value == null) return ByteBufferUtil.EMPTY_BYTE_BUFFER;
       
        BigInteger bi = value.unscaledValue();
        Integer scale = value.scale();
        byte[] bibytes = bi.toByteArray();
        byte[] sbytes = ByteBufferUtil.bytes(scale).array();
        byte[] bytes = new byte[bi.toByteArray().length+4];
       
        for (int i = 0 ; i < 4 ; i++) bytes[i] = sbytes[i];
        for (int i = 4 ; i < bibytes.length+4 ; i++) bytes[i] = bibytes[i-4];
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.