Java BigInteger Calculate serializeModexpNoBase(BigInteger[] modexp, boolean withResult)

Here you can find the source of serializeModexpNoBase(BigInteger[] modexp, boolean withResult)

Description

Helper method creating the JSON string for a single modexp without base and with or without given result.

License

MIT License

Parameter

Parameter Description
modexp the modexp to serialize
withResult true to include result, false to omit

Return

A JSON representation of modexp

Declaration

static String serializeModexpNoBase(BigInteger[] modexp, boolean withResult) 

Method Source Code


//package com.java2s;
/*/*from  www  .  j  a v a  2 s .c  om*/
 * Copyright 2016 Pascal Mainini
 * Licensed under MIT license, see included file LICENSE or
 * http://opensource.org/licenses/MIT
 */

import java.math.BigInteger;

public class Main {
    /**
    * Helper method creating the JSON string for a single modexp without base and with or without given result.
    * @param modexp the modexp to serialize
    * @param withResult true to include result, false to omit
    * @return A JSON representation of modexp
    */
    static String serializeModexpNoBase(BigInteger[] modexp, boolean withResult) {
        return withResult
                ? String.format("{\"m\":\"%s\",\"e\":\"%s\",\"r\":\"%s\"}", modexp[0].toString(16),
                        modexp[2].toString(16), modexp[3].toString(16))
                : String.format("{\"m\":\"%s\",\"e\":\"%s\"}", modexp[0].toString(16), modexp[2].toString(16));
    }
}

Related

  1. renderBigInteger(final BigInteger bint)
  2. retrieveBigInteger(final byte[] buf, final int offset)
  3. rightshift(byte b1, BigInteger b2)
  4. saveKey(File destDir, String fileName, BigInteger modulus, BigInteger publicExponent)
  5. saveToFile(String fileName, BigInteger mod, BigInteger exp)
  6. serializeModexpResponse(BigInteger response)
  7. serializeQuery(BigInteger modulus, BigInteger base, BigInteger exponent, boolean brief, String... modexps)
  8. shift(BigInteger integer, int distance)
  9. shiftLeft(final BigInteger register, final BigInteger input, final int n)