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 8900981
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T01:14:08+00:00 2026-06-15T01:14:08+00:00

I am implementing an encryption algorithm which uses large numbers, so while making a

  • 0

I am implementing an encryption algorithm which uses large numbers, so while making a java application I have to use the class BigInteger.

However, when I tried to implement the same in an android application the constructor

public BigInteger(int bitLength,int certainty,Random rnd), 

no random BigInteger is generated (The same integer is generated again and again 35879 :P) . A random BigInteger is generated successfully in a simple java Application.

For a reference,

http://docs.oracle.com/javase/7/docs/api/java/math/BigInteger.html#constructor_detail

Also, Please tell me if I import something of the form java.util.* , is it expected to work in any android application ??

Please make your comments if Android does not support BigInteger or any other class exists similar to that which is supported ???

Here the method systemoutprintln() is used for printing the respective string to a layout.

Here is a code for your reference,

public class keyGenerator {

/**
 * @param args the command line arguments
 */

  static  Vector check = new Vector();


  static protected BigInteger p= new BigInteger("161");
  static protected BigInteger q= new BigInteger("47");
  static protected Random s =new Random();
  static protected BigInteger n = new BigInteger("1");
  static protected BigInteger trails;
  static protected BigInteger lambda ;
  static protected BigInteger nsq  = new BigInteger("1");
  static protected BigInteger g = new BigInteger("1");
  static protected BigInteger temp = new BigInteger("1");
  static protected long timetkn;
  static protected View myview;
  static protected String[] printarray = new String[1000];
  static protected int ii=0;

static protected int maxbit;
private static BigInteger two = new BigInteger("2");

public keyGenerator() {

  //  Activity activity = new Activity();
// et.append("Second Part!!");
// EditText et = (EditText)activity.findViewById(R.string.second);
//    et.append("Working");


    long keyStart = SystemClock.uptimeMillis();
    p = new BigInteger(7,1,s);

            Systemoutprintln("Assumed p :" +p.toString());
  /*  while(!isPrime(p) && ( (p.compareTo(two)==1) || (p.compareTo(two))==0) )
    {
            p = new BigInteger(7,1,s);

    Systemoutprintln(p.toString());
    }*/


    Systemoutprintln("Assumed q :" +p.toString());
    q = new BigInteger(7,1,s);
  • 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-15T01:14:09+00:00Added an answer on June 15, 2026 at 1:14 am

    This should work, according to the java docs on Random numbers. However, I am noticing that you are printing the bigInteger p twice, with two different labels. Is it remotely possible that you are mixing them up?

    EDIT: With some help from digitaljoel, I found this prior quest:

    Is there a java equivalent to OpenSSL's bn_rand_range?

    Essentially, you should use SecureRandom, and use the method given there, namely:

    Random r = new SecureRandom();    
    BigInteger q = something_big;
    BigInteger ans;
    
    do
        BigInteger(bits_in_q, r);
    while (ans > q)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am implementing an application that needs to use TripleDES encryption with keys of
I am implementing a DES Encryption algorithm using C++, I benchmark it on a
Implementing the basic algorithm using last array as a pivot in Java, is it
I'm implementing encryption / decryption using Java Cipher and AES. Everything is working well
I plan on implementing some client-side hashing (and perhaps encryption) for an application I
I have written some (functional) AES encryption code using Java's built in encryption libraries,
I am implementing an application in which I must insert encrypted passwords into a
I use AES128 crypto in CTR mode for encryption, implemented for different clients (Android/Java
I am implementing a decryption of ciphertext using Rijndael's algorithm. Unfortunately, I have not
I'm looking for a secure symmetric-key encryption algorithm compatible with both JavaScript and Java.

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.