Here you can find the source of BigIntegerToEightBytes(BigInteger value)
Parameter | Description |
---|---|
value | BigInteger type |
Parameter | Description |
---|---|
Exception | Exception |
public static final byte[] BigIntegerToEightBytes(BigInteger value) throws Exception
//package com.java2s; /*//from ww w. ja v a2 s . c o m * Copyright (c) 2016 Tata Consultancy Services and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ import java.math.BigInteger; public class Main { /** * This function converts big integer to eight bytes. * * @param value * BigInteger type * @return value byte type * @throws Exception * Exception */ public static final byte[] BigIntegerToEightBytes(BigInteger value) throws Exception { byte[] result = new byte[8]; byte[] tmp = value.toByteArray(); if (tmp.length > 8) { System.arraycopy(tmp, tmp.length - 8, result, 0, 8); } else { System.arraycopy(tmp, 0, result, 8 - tmp.length, tmp.length); } return result; } }