2012-03-12 7 views
0

スポンジの城は"SHA1PRNG"アルゴリズムの実装を提供していますか? Bouncy Castleは "SHA1PRNG"アルゴリズムの実装を提供していないようですので、私はこれを求めています。Androidのスポンジの城

答えて

1

それは多分遅すぎるこの回答のために、しかし、ここでの実装例です:

SpongyCastleは、Androidで、BountyCastleと同じだけ使用可能であるべきです。

import java.security.SecureRandom; 
import java.security.Security; 


public class SHA1PRNG { 
//here i swapped out the bountycastle provider and used the spongycatle 
    static { 
     Security.addProvider(new org.spongycastle.jce.provider.BouncyCastleProvider()); 
} 

public static void main(String[] args) throws Exception { 

    SecureRandom rng = SecureRandom.getInstance("SHA1PRNG"); 
    rng.setSeed(711); 

    int numberToGenerate = 999; 
    byte randNumbers[] = new byte[numberToGenerate]; 

    rng.nextBytes(randNumbers); 
    for(int j=0; j<numberToGenerate; j++) { 
     System.out.print(randNumbers[j] + " "); 
    } 

} 
} 

から: www.java2s.com/Code/Java/Security/SecureRandomSHA1PRNG.htm

関連する問題