2016-08-23 70 views

回答

10

您可以使用此提供更換 「加密」 爲SecureRandom的,它的工作對我來說罰款:

使用,

SecureRandom sr = SecureRandom.getInstance("SHA1PRNG", new CryptoProvider()); 

代替,

SecureRandom sr = SecureRandom.getInstance("SHA1PRNG","Crypto"); 

和你CryptoProvider類像如下所示,

import java.security.Provider; 
/** 
* Implementation of Provider for SecureRandom. The implementation  supports the 
* "SHA1PRNG" algorithm described in JavaTM Cryptography Architecture, API 
* Specification & Reference 
*/ 
public final class CryptoProvider extends Provider { 
    /** 
* Creates a Provider and puts parameters 
*/ 
public CryptoProvider() { 
    super("Crypto", 1.0, "HARMONY (SHA1 digest; SecureRandom; SHA1withDSA signature)"); 
    put("SecureRandom.SHA1PRNG", 
      "org.apache.harmony.security.provider.crypto.SHA1PRNG_SecureRandomImpl"); 
    put("SecureRandom.SHA1PRNG ImplementedIn", "Software"); 
} 
} 
+0

謝謝,這就像一個魅力。你能簡要解釋一下嗎? – Neo

+0

它的工作!至少在實際採用推薦方式之前,這可以是一個快速修復。 – Mangesh

相關問題