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


Java PublicKey类代码示例

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


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

示例1: testAcceptKeyPairs

import org.abstractj.kalium.keys.PublicKey; //导入依赖的package包/类
@Test
public void testAcceptKeyPairs() throws Exception {
    try {
        new Box(new PublicKey(ALICE_PUBLIC_KEY), new PrivateKey(BOB_PRIVATE_KEY));
    } catch (Exception e) {
        fail("Box should accept key pairs");
    }
}
 
开发者ID:abstractj,项目名称:kalium,代码行数:9,代码来源:BoxTest.java

示例2: testEncryptRawBytes

import org.abstractj.kalium.keys.PublicKey; //导入依赖的package包/类
@Test
public void testEncryptRawBytes() throws Exception {
    Box box = new Box(new PublicKey(ALICE_PUBLIC_KEY), new PrivateKey(BOB_PRIVATE_KEY));
    byte[] nonce = HEX.decode(BOX_NONCE);
    byte[] message = HEX.decode(BOX_MESSAGE);
    byte[] ciphertext = HEX.decode(BOX_CIPHERTEXT);

    byte[] result = box.encrypt(nonce, message);
    assertTrue("failed to generate ciphertext", Arrays.equals(result, ciphertext));
}
 
开发者ID:abstractj,项目名称:kalium,代码行数:11,代码来源:BoxTest.java

示例3: testDecryptRawBytes

import org.abstractj.kalium.keys.PublicKey; //导入依赖的package包/类
@Test
public void testDecryptRawBytes() throws Exception {
    Box box = new Box(new PublicKey(ALICE_PUBLIC_KEY), new PrivateKey(BOB_PRIVATE_KEY));
    byte[] nonce = HEX.decode(BOX_NONCE);
    byte[] expectedMessage = HEX.decode(BOX_MESSAGE);
    byte[] ciphertext = box.encrypt(nonce, expectedMessage);

    Box pandora = new Box(new PublicKey(BOB_PUBLIC_KEY), new PrivateKey(ALICE_PRIVATE_KEY));
    byte[] message = pandora.decrypt(nonce, ciphertext);
    assertTrue("failed to decrypt ciphertext", Arrays.equals(message, expectedMessage));
}
 
开发者ID:abstractj,项目名称:kalium,代码行数:12,代码来源:BoxTest.java

示例4: testEncryptHexBytes

import org.abstractj.kalium.keys.PublicKey; //导入依赖的package包/类
@Test
public void testEncryptHexBytes() throws Exception {
    Box box = new Box(new PublicKey(ALICE_PUBLIC_KEY), new PrivateKey(BOB_PRIVATE_KEY));
    byte[] ciphertext = HEX.decode(BOX_CIPHERTEXT);

    byte[] result = box.encrypt(BOX_NONCE, BOX_MESSAGE, HEX);
    assertTrue("failed to generate ciphertext", Arrays.equals(result, ciphertext));
}
 
开发者ID:abstractj,项目名称:kalium,代码行数:9,代码来源:BoxTest.java

示例5: testDecryptHexBytes

import org.abstractj.kalium.keys.PublicKey; //导入依赖的package包/类
@Test
public void testDecryptHexBytes() throws Exception {
    Box box = new Box(new PublicKey(ALICE_PUBLIC_KEY), new PrivateKey(BOB_PRIVATE_KEY));
    byte[] expectedMessage = HEX.decode(BOX_MESSAGE);
    byte[] ciphertext = box.encrypt(BOX_NONCE, BOX_MESSAGE, HEX);

    Box pandora = new Box(new PublicKey(BOB_PUBLIC_KEY), new PrivateKey(ALICE_PRIVATE_KEY));
    byte[] message = pandora.decrypt(BOX_NONCE, HEX.encode(ciphertext), HEX);
    assertTrue("failed to decrypt ciphertext", Arrays.equals(message, expectedMessage));
}
 
开发者ID:abstractj,项目名称:kalium,代码行数:11,代码来源:BoxTest.java

示例6: testDecryptCorruptedCipherText

import org.abstractj.kalium.keys.PublicKey; //导入依赖的package包/类
@Test(expected = RuntimeException.class)
public void testDecryptCorruptedCipherText() throws Exception {
    Box box = new Box(new PublicKey(ALICE_PUBLIC_KEY), new PrivateKey(BOB_PRIVATE_KEY));
    byte[] nonce = HEX.decode(BOX_NONCE);
    byte[] message = HEX.decode(BOX_MESSAGE);
    byte[] ciphertext = box.encrypt(nonce, message);
    ciphertext[23] = ' ';

    Box pandora = new Box(new PublicKey(BOB_PUBLIC_KEY), new PrivateKey(ALICE_PRIVATE_KEY));
    pandora.decrypt(nonce, ciphertext);
    fail("Should raise an exception");
}
 
开发者ID:abstractj,项目名称:kalium,代码行数:13,代码来源:BoxTest.java

示例7: Box

import org.abstractj.kalium.keys.PublicKey; //导入依赖的package包/类
public Box(PublicKey publicKey, PrivateKey privateKey) {
    this(publicKey.toBytes(), privateKey.toBytes());
}
 
开发者ID:duniter,项目名称:duniter-android-app,代码行数:4,代码来源:Box.java

示例8: testNullPublicKey

import org.abstractj.kalium.keys.PublicKey; //导入依赖的package包/类
@Test(expected = RuntimeException.class)
public void testNullPublicKey() throws Exception {
    String key = null;
    new Box(new PublicKey(key), new PrivateKey(BOB_PRIVATE_KEY));
    fail("Should raise an exception");
}
 
开发者ID:abstractj,项目名称:kalium,代码行数:7,代码来源:BoxTest.java

示例9: testInvalidPublicKey

import org.abstractj.kalium.keys.PublicKey; //导入依赖的package包/类
@Test(expected = RuntimeException.class)
public void testInvalidPublicKey() throws Exception {
    String key = "hello";
    new Box(new PublicKey(key), new PrivateKey(BOB_PRIVATE_KEY));
    fail("Should raise an exception");
}
 
开发者ID:abstractj,项目名称:kalium,代码行数:7,代码来源:BoxTest.java

示例10: testNullSecretKey

import org.abstractj.kalium.keys.PublicKey; //导入依赖的package包/类
@Test(expected = RuntimeException.class)
public void testNullSecretKey() throws Exception {
    String key = null;
    new Box(new PublicKey(ALICE_PUBLIC_KEY), new PrivateKey(key));
    fail("Should raise an exception");
}
 
开发者ID:abstractj,项目名称:kalium,代码行数:7,代码来源:BoxTest.java

示例11: testInvalidSecretKey

import org.abstractj.kalium.keys.PublicKey; //导入依赖的package包/类
@Test(expected = RuntimeException.class)
public void testInvalidSecretKey() throws Exception {
    String key = "hello";
    new Box(new PublicKey(ALICE_PUBLIC_KEY), new PrivateKey(key));
    fail("Should raise an exception");
}
 
开发者ID:abstractj,项目名称:kalium,代码行数:7,代码来源:BoxTest.java


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