Here you can find the source of trim(BigInteger n)
Parameter | Description |
---|---|
in | the byte array to trim. |
public static byte[] trim(BigInteger n)
//package com.java2s; // the terms and conditions of the Cryptix General Licence. You should have import java.math.BigInteger; public class Main { /**//from w ww . ja v a 2s .c om * Treats the input as the MSB representation of a number, and lop off * leading zero elements. For efficiency, the input is simply returned if no * leading zeroes are found. * * @param in the byte array to trim. * @return the byte array with no leading 0-bytes. */ public static byte[] trim(BigInteger n) { byte[] in = n.toByteArray(); if (in.length == 0 || in[0] != 0) return in; int len = in.length; int i = 1; while (in[i] == 0 && i < len) ++i; byte[] ret = new byte[len - i]; System.arraycopy(in, i, ret, 0, len - i); return ret; } }