当前位置: 首页>>代码示例>>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;未经允许,请勿转载。