私は多数を使用する暗号化アルゴリズムを実装しているため、Java アプリケーションを作成する際にクラス BigInteger を使用する必要があります。
ただし、Androidアプリケーションで同じものを実装しようとすると、コンストラクター
public BigInteger(int bitLength,int certainty,Random rnd),
ランダムな BigInteger は生成されません (同じ整数が何度も生成されます 35879 :P)。単純な Java アプリケーションで、ランダムな BigInteger が正常に生成されます。
参考までに、
http://docs.oracle.com/javase/7/docs/api/java/math/BigInteger.html#constructor_detail
また、 java.util.* の形式のものをインポートするかどうか教えてください。どの Android アプリケーションでも動作すると予想されますか??
Android が BigInteger をサポートしていない場合、またはサポートされているクラスと同様のクラスが他に存在する場合は、コメントしてください。
ここでは、メソッド systemoutprintln() を使用して、それぞれの文字列をレイアウトに出力しています。
ここにあなたの参照のためのコードがあります、
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);