mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-11-10 20:06:37 +01:00
@@ -32,12 +32,12 @@ actual fun sha256(data: ByteArray) = pool.hash(data)
|
|||||||
* This is more efficient than reading the stream twice.
|
* This is more efficient than reading the stream twice.
|
||||||
*
|
*
|
||||||
* @param inputStream The input stream to hash
|
* @param inputStream The input stream to hash
|
||||||
* @param bufferSize Size of chunks to read (default 64KB)
|
* @param bufferSize Size of chunks to read (default 8KB)
|
||||||
* @return Pair of (hash bytes, bytes read count)
|
* @return Pair of (hash bytes, bytes read count)
|
||||||
*/
|
*/
|
||||||
fun sha256StreamWithCount(
|
fun sha256StreamWithCount(
|
||||||
inputStream: InputStream,
|
inputStream: InputStream,
|
||||||
bufferSize: Int = 65536,
|
bufferSize: Int = 8192,
|
||||||
): Pair<ByteArray, Long> {
|
): Pair<ByteArray, Long> {
|
||||||
val countingStream = CountingInputStream(inputStream)
|
val countingStream = CountingInputStream(inputStream)
|
||||||
val hash = pool.hashStream(countingStream, bufferSize)
|
val hash = pool.hashStream(countingStream, bufferSize)
|
||||||
|
|||||||
@@ -37,12 +37,12 @@ class Sha256Hasher {
|
|||||||
* This avoids loading the entire input into memory at once.
|
* This avoids loading the entire input into memory at once.
|
||||||
*
|
*
|
||||||
* @param inputStream The input stream to hash
|
* @param inputStream The input stream to hash
|
||||||
* @param bufferSize Size of chunks to read (default 64KB)
|
* @param bufferSize Size of chunks to read (default 8KB)
|
||||||
* @return SHA256 hash bytes
|
* @return SHA256 hash bytes
|
||||||
*/
|
*/
|
||||||
fun hashStream(
|
fun hashStream(
|
||||||
inputStream: InputStream,
|
inputStream: InputStream,
|
||||||
bufferSize: Int = 65536,
|
bufferSize: Int = 8192,
|
||||||
): ByteArray {
|
): ByteArray {
|
||||||
val buffer = ByteArray(bufferSize)
|
val buffer = ByteArray(bufferSize)
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -61,12 +61,12 @@ class Sha256Pool(
|
|||||||
* This avoids loading the entire input into memory at once.
|
* This avoids loading the entire input into memory at once.
|
||||||
*
|
*
|
||||||
* @param inputStream The input stream to hash
|
* @param inputStream The input stream to hash
|
||||||
* @param bufferSize Size of chunks to read (default 64KB)
|
* @param bufferSize Size of chunks to read (default 8KB)
|
||||||
* @return SHA256 hash bytes
|
* @return SHA256 hash bytes
|
||||||
*/
|
*/
|
||||||
fun hashStream(
|
fun hashStream(
|
||||||
inputStream: InputStream,
|
inputStream: InputStream,
|
||||||
bufferSize: Int = 65536,
|
bufferSize: Int = 8192,
|
||||||
): ByteArray {
|
): ByteArray {
|
||||||
val hasher = acquire()
|
val hasher = acquire()
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user