use of io.nem.symbol.core.crypto.CryptoException in project nem2-sdk-java by nemtech.
the class EncryptedMessageTest method testDecryptWrong.
@Test
public void testDecryptWrong() {
String wrongEncrypted = "ABCD";
KeyPair sender = KeyPair.random();
KeyPair recipient = KeyPair.random();
EncryptedMessage encryptedMessage = new EncryptedMessage(wrongEncrypted);
Assertions.assertEquals(MessageType.ENCRYPTED_MESSAGE, encryptedMessage.getType());
CryptoException e = Assertions.assertThrows(CryptoException.class, () -> encryptedMessage.decryptPayload(sender.getPublicKey(), recipient.getPrivateKey()));
Assertions.assertEquals("Cannot decrypt input. Size is 2 when at least 28 is expected.", e.getMessage());
}
Aggregations