小编byk*_*lak的帖子

Java中巨大的BigIntegers更快的素数因子分解

所以我现在正在研究一个java代码.我已经完全正常工作,但是任务的重点是使它分解大数(超过30位).这样做,但它可能需要15分钟才能完成,这是不行的.我的教授向我保证,我使用的算法适用于最多2 ^ 70的数字,并且应该在大约五分钟内完成.我一直试图想出办法(增加2而不是1等),但我似乎无法弄清楚如何在不跳过某些因素的情况下让它更快地移动.有任何想法吗?我还认为Elliptic Curve方法会更好,但他告诉我现在不要处理它.

这是我的代码(ps,sqrt是我自己的函数,但我确信它正在工作):

public String factorizer(BigInteger monster){
    System.out.println("monster =" + monster); 
    String factors = "";  
    BigInteger top = maths.monsterSqrt(monster);   
    if(monster.mod(two).equals(0));
        BigInteger jump = two;
    for(BigInteger bi = two; bi.compareTo(top) <= 0; bi = bi.add(jump)){
        while(monster.mod(bi).equals(zero)){
            factors +=  "+" + bi + ""; 
            monster = monster.divide(bi); 
            jump = one; 
        }
    }
    if(monster.compareTo(BigInteger.ONE) == 1){
        factors  += "+" + monster; 
    } 
    return factors; 
} 
Run Code Online (Sandbox Code Playgroud)

java cryptography rsa factorization

2
推荐指数
1
解决办法
7445
查看次数

标签 统计

cryptography ×1

factorization ×1

java ×1

rsa ×1