Skip to content

Commit 48fd0ca

Browse files
SessionHero01SessionHero01
authored andcommitted
Added comments
1 parent b57a6bd commit 48fd0ca

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

library/src/main/java/network/loki/messenger/libsession_util/encrypt/DecryptionStream.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@ package network.loki.messenger.libsession_util.encrypt
33
import java.io.InputStream
44
import java.nio.ByteBuffer
55

6+
/**
7+
* A stream for decrypting data that was encrypted using [EncryptionStream].
8+
*
9+
* Note that you don't need to specify the chunk size as it would have been encoded into the stream.
10+
*
11+
* @param inStream the underlying input stream to read encrypted data from.
12+
* @param key the decryption key to use for decrypting data, must be 32 bytes long.
13+
* @param autoClose whether to automatically close the underlying input stream when this stream is
14+
*/
615
class DecryptionStream(
716
private val inStream: InputStream,
817
key: ByteArray,

library/src/main/java/network/loki/messenger/libsession_util/encrypt/EncryptionStream.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,18 @@ package network.loki.messenger.libsession_util.encrypt
33
import java.io.OutputStream
44
import java.nio.ByteBuffer
55

6+
/**
7+
* An [OutputStream] that encrypts data on the fly, using libsodium's encryption stream API.
8+
*
9+
* Note that you must ensure this stream is flushed at the end, or you can call [close] (which you
10+
* should always do) to make sure all data is written out.
11+
*
12+
* @param out the underlying output stream to write encrypted data to.
13+
* @param key the encryption key to use for encrypting data, must be 32 bytes long.
14+
* @param chunkSize the size of chunks to write to the output stream. The bigger the chunk size,
15+
* the more memory is used, but the less overhead there is for each write operation.
16+
* @param autoClose whether to automatically close the underlying output stream when this stream is closed.
17+
*/
618
class EncryptionStream(
719
private val out: OutputStream,
820
key: ByteArray,

0 commit comments

Comments
 (0)