encryptData
public static void encryptData(Data data,
Blob payload,
Name keyName,
Blob key,
EncryptParams params)
throws NoSuchAlgorithmException,
NoSuchPaddingException,
InvalidKeyException,
IllegalBlockSizeException,
BadPaddingException,
InvalidAlgorithmParameterException,
InvalidKeySpecException
Prepare an encrypted data packet by encrypting the payload using the key
according to the params. In addition, this prepares the encoded
EncryptedContent with the encryption result using keyName and params. The
encoding is set as the content of the data packet. If params defines an
asymmetric encryption algorithm and the payload is larger than the maximum
plaintext size, this encrypts the payload with a symmetric key that is
asymmetrically encrypted and provided as a nonce in the content of the data
packet. The packet's /{dataName}/ is updated to be
/{dataName}/FOR/{keyName}
- Parameters:
data - The data packet which is updated.
payload - The payload to encrypt.
keyName - The key name for the EncryptedContent.
key - The encryption key value.
params - The parameters for encryption.
- Throws:
NoSuchAlgorithmException
NoSuchPaddingException
InvalidKeyException
IllegalBlockSizeException
BadPaddingException
InvalidAlgorithmParameterException
InvalidKeySpecException