Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.math.BigInteger;

public class Main {
    public static String encodeBigInteger(BigInteger v) {
        return bytesToHex(v.toByteArray());
    }

    /**
     * Transformts the byte array to a
     * hexadecimal String
     * @param in byte array
     * @return hexstring
     */
    public static String bytesToHex(byte[] in) {
        final StringBuilder builder = new StringBuilder();
        for (byte b : in) {
            builder.append(String.format("%02x", b));
        }
        return builder.toString();
    }
}