Here you can find the source of modPowByte(byte[] arg, BigInteger e, BigInteger n)
public static byte[] modPowByte(byte[] arg, BigInteger e, BigInteger n)
//package com.java2s; //License from project: Open Source License import java.math.BigInteger; public class Main { public static byte[] modPowByte(byte[] arg, BigInteger e, BigInteger n) { BigInteger source = new BigInteger(1, arg); BigInteger result = source.modPow(e, n); return getBytesWithoutSign(result); }//from www . ja v a 2 s . c o m private static byte[] getBytesWithoutSign(BigInteger arg) { byte[] sourceArray = arg.toByteArray(); if (sourceArray[0] != 0) { return sourceArray; } else { byte[] withoutSign = new byte[sourceArray.length - 1]; System.arraycopy(sourceArray, 1, withoutSign, 0, withoutSign.length); return withoutSign; } } }