Java BigInteger Calculate getPrivateKeyBytes(BigInteger privateKey)

Here you can find the source of getPrivateKeyBytes(BigInteger privateKey)

Description

get Private Key Bytes

License

Apache License

Declaration

public static byte[] getPrivateKeyBytes(BigInteger privateKey) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.math.BigInteger;

public class Main {
    public static byte[] getPrivateKeyBytes(BigInteger privateKey) {
        byte[] privateKeyPlainNumber = privateKey.toByteArray();
        int plainNumbersOffs = privateKeyPlainNumber[0] == 0 ? 1 : 0;
        byte[] privateKeyBytes = new byte[32];
        System.arraycopy(privateKeyPlainNumber, plainNumbersOffs, privateKeyBytes,
                privateKeyBytes.length - (privateKeyPlainNumber.length - plainNumbersOffs),
                privateKeyPlainNumber.length - plainNumbersOffs);
        return privateKeyBytes;
    }// w w w .j a va  2 s.  com
}

Related

  1. getNetAddress(BigInteger ip, BigInteger netmask)
  2. getNextLexicographicalPermutation(BigInteger v)
  3. getNRightmostBits(final BigInteger in, final int n)
  4. getNumbersBetweenRange(BigInteger minValue, BigInteger maxValue)
  5. getPrivateKey(BigInteger ran, BigInteger publicKey)
  6. getQosFlowId(short tableId, BigInteger dpId, int lportTag)
  7. getRadixNumberInString(BigInteger integerNumber, int radix)
  8. getRandomBigInteger(int bits)
  9. getRandomInteger(BigInteger n, Random rand)