Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7802945
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T01:24:43+00:00 2026-06-02T01:24:43+00:00

I have the following code: BigInteger d = new BigInteger(1,NFCUtil.hexStringToByteArray(IssPrivKey)); BigInteger n = new

  • 0

I have the following code:

BigInteger d = new BigInteger(1,NFCUtil.hexStringToByteArray(IssPrivKey));
BigInteger n = new BigInteger(1,NFCUtil.hexStringToByteArray(IssPubKeyMod));
BigInteger X = new BigInteger(1,NFCUtil.hexStringToByteArray(unsignedPhoneCert));

BigInteger iccCertBI = X.modPow(d, n);

final String iccCert = iccCertBI.toString(16);

System.out.println("\nSigned Certificate: (int)" + iccCertBI +
            "\nSigned Certificate (hex): "+iccCert + 
            "\nsigned Cert length: "+iccCert.length());

What I’m doing is signing a String using a private exponent and the public modulus. All lengths are 288 chars or 144 bytes. The kicker is when I use it for the following String:

//Length 144
    final String unsignedTerCert="6A04846983677983FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF121" +
            "3AFAFAF01018001BDB011D89730D7958DCAF0D34A4668A65073F2766BAC3C3E7D551211A" +
            "1D7896085F1F4FDAA9A256579B0D4D6B1C7CF6C88D318886C55FB3CA91DB721376797058" +
            "F482A51A363B92A89DA81BB6A7FFBB6F8C8E109E5909EFFFFFFFFFFFFFFFFFFFFFFFFFFF" +
            "FFFFFFFFFFFFFBC";

It gives me back a String of length 288 chars or 144 bytes, just as I’m expecting.

However using it with:

//Length 144
    final String unsignedPhoneCert="6A0400112233445566778899011401020301018001AE0A3CCBF6B1A997E4A4AEC7EDA6697F6B73C2EC18F8E3403F83237BD9863B4CD0BE0EBC2A8E3FB140251935F1D4EAEF2D7801FFC2CF36328E234676F96883BAB6547F82FE02455B59B6952231B130EE70980B74456168AD2A511A00448BFEA62593DCF9F3D9FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFBC";

Gives me back a String of length 287 chars.

So my question, is there something in the BigInteger toString(16) method that’s causing this?

NB. I can still decrypt both of them fine from BigInteger using the public key expo, so that’s what makes me think it’s something to do with the .toString() method.

Any help/hints would be appreciated, thanks.

EDIT: Here’s the outputs I’m getting from the incorrect one:

Expo:36652731434641292350412815683229009979770975413220344544898857375896901092978000426765621805499026545042319009684553729382562239973283276192079521889464379604341193094271888918244826201023503324034315850394178807890994288745747556760470026279678747937975742329807945656583328292494373708777822442236249197245972251059241540578219194613740104635899
X:25332900759103924912689760614898214526937827890939506310067994686010108648336498000719255096072122266248508522922053911850606613923138698430079380374971383359222723175609119386369637533489684435824557964231714784677160255389973258884831385632708921103814163273457386881057406862373463121304854072959526597286211022281774584184894225094204257730492
X (hex):6a0400112233445566778899011401020301018001ae0a3ccbf6b1a997e4a4aec7eda6697f6b73c2ec18f8e3403f83237bd9863b4cd0be0ebc2a8e3fb140251935f1d4eaef2d7801ffc2cf36328e234676f96883bab6547f82fe02455b59b6952231b130ee70980b74456168ad2a511a00448bfea62593dcf9f3d9ffffffffffffffffffffffffffffffffffffffffbc

    Phone Signed Certificate: (int)2621041784071301050954845366555843081386290833242762939438653553587304361236513516037765146640763105648748143029523335470875071401132351534501879861341081099809142476414060273707263492268408647346182500147665413648376803840594353667155297685676942776395991299461798048817170064783101287983256626056086159016336001344190438106860395808579588320414
    Phone Signed Certificate (hex): af802ec9b412c2e223e28cd0e540255b18351d570e24690b1b441f6e084afb3a03a6a1a52ec4268d9dacf47385222011a977994c9dc521dc4ca82f20f4345ee8697a1cc269931211640efe7b6d29c728283aa823525887f09dbc6df37f3e1a6ec4718ccbb31778d813e4375d89631503dc785c9c9eb4770e918a3cc37c90b6d75135d8c32c299d8096d4bd88199ec9e
     Phone signed Cert length: 287

And from the correct one:

Expo:36652731434641292350412815683229009979770975413220344544898857375896901092978000426765621805499026545042319009684553729382562239973283276192079521889464379604341193094271888918244826201023503324034315850394178807890994288745747556760470026279678747937975742329807945656583328292494373708777822442236249197245972251059241540578219194613740104635899
X:25333383310317922886770001828148668452338535025796085964448660925847832365078972818630528414968514941209307982589233259227108935074767908506952878286644207041412726931112453402165128539381501316868062159358826581046954850027043009445846574678562969939333097216245548333577227051225788418683968135213089604118672442657593365304099582656739524214716
X (hex):6a04846983677983ffffffffffffffffffffffffffffffffffffff1213afafaf01018001bdb011d89730d7958dcaf0d34a4668a65073f2766bac3c3e7d551211a1d7896085f1f4fdaa9a256579b0d4d6b1c7cf6c88d318886c55fb3ca91db721376797058f482a51a363b92a89da81bb6a7ffbb6f8c8e109e5909effffffffffffffffffffffffffffffffffffffffbc

Phone Signed Certificate: (int)21432015836175396598983285831512248305709761145636099501338782160749145447638782142594889169355603470185237110648036474961995187557563452989823081731645192439732733979910407327875747461117018365485531108584396064685039171356192052384601156809092826847482291755881176360680132279291900385137689881779233791387498805975645418591098518000313085841654
Phone Signed Certificate (hex): 59b0d96873fa0895d52d3f63475dd224c0a73bc34439e369a7b5eea88fd65b52464317b88642016421e9054d7e19dfc9cac7ffda07faea496268ea133cd83dc45959de61b1aa4b26a46ab47c6b8f4f2c092e914f0d940e9082b800119eba061bf7a654c022bc9c601a2d02a9775fb2cd23e532146443d7236c2ab301478fc9c59bbd984792d95d1db1a8d2ce80add0f6
 Phone signed Cert length: 288
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T01:24:45+00:00Added an answer on June 2, 2026 at 1:24 am

    BigInteger.toString(int) will not pad its output with leading zeroes. If you want a fixed-width output, try String.format:

    String.format("%0288x", iccCertBI)
    

    ADD

    The format string breaks down as follows:

    • % marks the beginning of the format specifier, which tells the formatter to put the corresponding argument at this position in the output.
    • 0 tells the formatter to use zero-padding; without this it uses spaces for padding.
    • 288 tells the formatter to produce a minimum of 288 characters in the output (not sure if you can specify a maximum)
    • x tells the the formatter to convert the corresponding argument as a hexidecimal integer (any numeric primitive or type, such as int, long. or BigInteger, will work here).

    String.format is a powerful tool for formatting common datatypes as strings, you should definitely read up on the Javadoc.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have following code snippet in c#. var list = new List<string> { a,
I have the following code at the head of a method: BigInteger foo =
I have following code class User attr_accessor :name end u = User.new u.name =
I have following code snipped: ... var tpc = new ThirtPartyClass(); tpc.ExecuteCommand(); tpc.ExecuteCommand(); ...
I have following code in C# PasswordDeriveBytes DerivedPassword = new PasswordDeriveBytes(Password, SaltValueBytes, HashAlgorithm, PasswordIterations);
I have following code in C# PasswordDeriveBytes DerivedPassword = new PasswordDeriveBytes(Password, SaltValueBytes, HashAlgorithm, PasswordIterations);
I have following code: string date = 13.04.2012; string date2 = (DateTime.Parse(date).AddDays(1)).ToString(); This is
I have following code function Model(onChanged) { this.array = new Array(); this.onChanged = onChanged;
Have following code: public interface ITest { string St1 { get; } } public
I have following code to serialize my data into a file: out = new

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.