本文整理汇总了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");
}
}
示例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));
}
示例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));
}
示例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));
}
示例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));
}
示例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");
}
示例7: Box
import org.abstractj.kalium.keys.PublicKey; //导入依赖的package包/类
public Box(PublicKey publicKey, PrivateKey privateKey) {
this(publicKey.toBytes(), privateKey.toBytes());
}
示例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");
}
示例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");
}
示例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");
}
示例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");
}