當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。