當前位置: 首頁>>代碼示例>>Java>>正文


Java SecureRandomSpi類代碼示例

本文整理匯總了Java中java.security.SecureRandomSpi的典型用法代碼示例。如果您正苦於以下問題:Java SecureRandomSpi類的具體用法?Java SecureRandomSpi怎麽用?Java SecureRandomSpi使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


SecureRandomSpi類屬於java.security包,在下文中一共展示了SecureRandomSpi類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: create

import java.security.SecureRandomSpi; //導入依賴的package包/類
public SecureRandomSpi create(Object constructorParam) {
    try {
        return Adaptor.adapt(type.newInstance(), SecureRandomSpi.class);
    } catch (Exception e) {
        throw new IllegalArgumentException("Invalid type: " + type, e);
    }
}
 
開發者ID:ivanceras,項目名稱:crypto-gwt,代碼行數:8,代碼來源:SecureRandomSpiFactory.java

示例2: test

import java.security.SecureRandomSpi; //導入依賴的package包/類
public int test() {
    if ("failed".equalsIgnoreCase(Security.getProperty("policy.allowSystemProperty"))) {
        return error("An extra policy feature is disabled by default.");
    }
    
    System.setSecurityManager(new SecurityManager());       
    
    Provider p = new SecureRandomProvider(ProviderName, Version, Description);
    if (p == null) {
        return fail("Couldn't create secure random provider. Test failed.");           
    }
    
    SecureRandomSpi secureRandomSpi = new SecureRandomSPImplementation();
    if (secureRandomSpi == null) {
        return fail("Couldn't create an instance of SecureRandomSPImplementation. Test failed.");
    }
    
    Security.addProvider(p);
    SecureRandom random = new MySecureRandom(secureRandomSpi, p);        
    
    log.info("Generating seed...");
    byte[] seed = random.generateSeed(100);
    log.info("OK\nSeeding pseudo-random number generator...");
    random.setSeed(seed);
    log.info("OK\nGetting pseudo-random numbers...");
    byte[] numbers = new byte[10];        
    random.nextBytes(numbers);
    log.info("OK");
    
    return pass("Test passed");
}
 
開發者ID:freeVM,項目名稱:freeVM,代碼行數:32,代碼來源:F_SecureRandomTest_04.java

示例3: BadRandom

import java.security.SecureRandomSpi; //導入依賴的package包/類
public BadRandom(Random r, SecureRandomSpi secureRandomSpi, Provider provider) {
    this.r = r;
}
 
開發者ID:RUB-NDS,項目名稱:ModifiableVariable,代碼行數:4,代碼來源:BadRandom.java

示例4: EntropyGathererBase

import java.security.SecureRandomSpi; //導入依賴的package包/類
protected EntropyGathererBase(String name)
{
	jvmRandom = new SecureRandom();

	random = new DigestRandomGenerator(new SHA512Digest());
	
	spi = new SecureRandomSpi()
	{
		private boolean init = true;
		
		protected final void engineSetSeed(byte[] seed)
		{
			random.addSeedMaterial(seed);
		}

		protected final void engineNextBytes(byte[] bytes)
		{
			if(init)
			{
				// initialize generator with randomness from jvm
				random.addSeedMaterial(jvmRandom.generateSeed(256));
				init = false;
			}
			else
			{
				random.addSeedMaterial(jvmRandom.nextLong());					
			}
			
			random.addSeedMaterial(System.currentTimeMillis());
			random.addSeedMaterial(Runtime.getRuntime().freeMemory());
			random.addSeedMaterial(System.nanoTime());
			
			random.nextBytes(bytes);
		}

		protected final byte[] engineGenerateSeed(int numBytes)
		{
			byte[] b = new byte[numBytes];
			engineNextBytes(b);
			return b;
		}
	};
	
	provider = new Provider(name, 1.2, "andy goryachev") { };
}
 
開發者ID:andy-goryachev,項目名稱:PasswordSafe,代碼行數:46,代碼來源:EntropyGathererBase.java

示例5: MySecureRandom

import java.security.SecureRandomSpi; //導入依賴的package包/類
public MySecureRandom(SecureRandomSpi secureRandomSpi, Provider provider) {
    super(secureRandomSpi, provider);
}
 
開發者ID:Sellegit,項目名稱:j2objc,代碼行數:4,代碼來源:SecureRandom2Test.java

示例6: SecureRandomSpiFactory

import java.security.SecureRandomSpi; //導入依賴的package包/類
public SecureRandomSpiFactory(Class<? extends java.security.SecureRandomSpi> type) {
    this.type = type;
}
 
開發者ID:ivanceras,項目名稱:crypto-gwt,代碼行數:4,代碼來源:SecureRandomSpiFactory.java

示例7: MySecureRandom

import java.security.SecureRandomSpi; //導入依賴的package包/類
public MySecureRandom(SecureRandomSpi secureRandomSpi, Provider provider) {
    super(secureRandomSpi, provider);
    log.info("MySecureRandom ctor has been called.");
}
 
開發者ID:freeVM,項目名稱:freeVM,代碼行數:5,代碼來源:F_SecureRandomTest_04.java


注:本文中的java.security.SecureRandomSpi類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。