public class CommunicationHelper extends Object
Constructor and Description |
---|
CommunicationHelper() |
Modifier and Type | Method and Description |
---|---|
static void |
cypherAndSend(Message msg,
OutputStream out,
Cipher cipher)
This method encrypt and send the given data by adding at the begging of
the encrypted data the length of the data that will be sent
|
static Message |
readAndDecypher(InputStream is,
Cipher cipher)
Read data from a stream and decrypt it and convert to a
Message . |
public static void cypherAndSend(Message msg, OutputStream out, Cipher cipher) throws IOException, org.bouncycastle.crypto.CryptoException
msg
- the Message
to encrypt and to send over the streamout
- the stream where to send the datacipher
- the Cipher
to use for encrypting the original data
contentIOException
org.bouncycastle.crypto.CryptoException
public static Message readAndDecypher(InputStream is, Cipher cipher) throws IOException, ClassNotFoundException, org.bouncycastle.crypto.CryptoException
Message
.
The protocol read at the beginning 4 bytes representing the actual size
of the encrypted message that will follow.ois
- ObjectInputStream to read from acipher
- the Cipher
to use for decrypting the dataIOException
ClassNotFoundException
org.bouncycastle.crypto.CryptoException
Copyright © 2015 universAAL Consortium. All Rights Reserved.