当前位置: 首页>>代码示例>>Java>>正文


Java KeyczarKey类代码示例

本文整理汇总了Java中org.keyczar.KeyczarKey的典型用法代码示例。如果您正苦于以下问题:Java KeyczarKey类的具体用法?Java KeyczarKey怎么用?Java KeyczarKey使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


KeyczarKey类属于org.keyczar包,在下文中一共展示了KeyczarKey类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testEncryptKey

import org.keyczar.KeyczarKey; //导入依赖的package包/类
@Test
public void testEncryptKey() throws KeyczarException {
  GenericKeyczar key = Util.createKey(DefaultKeyType.AES, KeyPurpose.DECRYPT_AND_ENCRYPT);

  KeyczarKey k = key.getKey(key.getMetadata().getPrimaryVersion());
  String unencryptedKey = k.toString();
  String encrypted = KeyczarPBEReader.encryptKey(unencryptedKey, PASSPHRASE);

  PBEKeyczarKey pbeKey = KeyczarPBEReader.parsePBEMetadata(encrypted);
  assertEquals(KeyczarPBEReader.DEFAULT_ITERATION_COUNT, pbeKey.iterationCount);
  assertEquals(KeyczarPBEReader.SALT_BYTES, Base64Coder.decodeWebSafe(pbeKey.salt).length);
  assertEquals(KeyczarPBEReader.PBE_AES_KEY_BYTES, Base64Coder.decodeWebSafe(pbeKey.iv).length);

  // decrypt the key
  KeyczarPBEReader reader = new KeyczarPBEReader(null, PASSPHRASE);
  String out = reader.decryptKey(encrypted);
  assertEquals(unencryptedKey, out);
}
 
开发者ID:WeAreWizards,项目名称:passopolis-server,代码行数:19,代码来源:KeyczarPBEReaderTest.java

示例2: StaticKeyReader

import org.keyczar.KeyczarKey; //导入依赖的package包/类
StaticKeyReader(AesKey key) {
  this.metadata = new KeyMetadata(
          "Imported AES", KeyPurpose.DECRYPT_AND_ENCRYPT, DefaultKeyType.AES);
  KeyVersion version = new KeyVersion(0, KeyStatus.PRIMARY, false);
  this.metadata.addVersion(version);
  this.keys = new ArrayList<KeyczarKey>();
  this.keys.add(key);
}
 
开发者ID:WeAreWizards,项目名称:passopolis-server,代码行数:9,代码来源:JsonWriterTest.java

示例3: read

import org.keyczar.KeyczarKey; //导入依赖的package包/类
public abstract KeyczarKey read(String paramString)
throws KeyczarException;
 
开发者ID:ChiangC,项目名称:FMTech,代码行数:3,代码来源:KeyType.java

示例4: MemoryKeyReader

import org.keyczar.KeyczarKey; //导入依赖的package包/类
public MemoryKeyReader(KeyMetadata metadata, Map<Integer, KeyczarKey> keys) {
	this.metadata = metadata;
	this.keys = keys;
	assert keys == null || metadata.getVersions().size() == keys.size();
}
 
开发者ID:WeAreWizards,项目名称:passopolis-server,代码行数:6,代码来源:Util.java

示例5: readerFromKeyczar

import org.keyczar.KeyczarKey; //导入依赖的package包/类
/**
 * Create a KeyczarReader from an existing key. Useful for creating a GenericKeyczar
 * to manipulate a keyset, then "re-open" the key as the correct type to use it
 * Example: Crypter crypter = new Crypter(Util.readerFromKeyczar(keyczar));
 *
 * @param keyczar
 * @return
 */
public static KeyczarReader readerFromKeyczar(GenericKeyczar keyczar) {
	HashMap<Integer, KeyczarKey> keys = new HashMap<Integer, KeyczarKey>();
	for (KeyVersion v : keyczar.getVersions()) {
		keys.put(v.getVersionNumber(), keyczar.getKey(v));
	}
	return new MemoryKeyReader(keyczar.getMetadata(), keys);
}
 
开发者ID:WeAreWizards,项目名称:passopolis-server,代码行数:16,代码来源:Util.java


注:本文中的org.keyczar.KeyczarKey类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。