From 7254dce3a97d0e209b40467ced72333a58620bcf Mon Sep 17 00:00:00 2001 From: davotoula Date: Sun, 26 Oct 2025 10:25:40 +0100 Subject: [PATCH] Revert "update buffer to 64kb" This reverts commit 4e31a9a5ac8e9fc0924903963587e3f50233664f. --- .../vitorpamplona/quartz/utils/sha256/Sha256.jvmAndroid.kt | 4 ++-- .../quartz/utils/sha256/Sha256Hasher.jvmAndroid.kt | 4 ++-- .../quartz/utils/sha256/Sha256Pool.jvmAndroid.kt | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/quartz/src/jvmAndroid/kotlin/com/vitorpamplona/quartz/utils/sha256/Sha256.jvmAndroid.kt b/quartz/src/jvmAndroid/kotlin/com/vitorpamplona/quartz/utils/sha256/Sha256.jvmAndroid.kt index 25fffbde9..17234cfa9 100644 --- a/quartz/src/jvmAndroid/kotlin/com/vitorpamplona/quartz/utils/sha256/Sha256.jvmAndroid.kt +++ b/quartz/src/jvmAndroid/kotlin/com/vitorpamplona/quartz/utils/sha256/Sha256.jvmAndroid.kt @@ -32,12 +32,12 @@ actual fun sha256(data: ByteArray) = pool.hash(data) * This is more efficient than reading the stream twice. * * @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) */ fun sha256StreamWithCount( inputStream: InputStream, - bufferSize: Int = 65536, + bufferSize: Int = 8192, ): Pair { val countingStream = CountingInputStream(inputStream) val hash = pool.hashStream(countingStream, bufferSize) diff --git a/quartz/src/jvmAndroid/kotlin/com/vitorpamplona/quartz/utils/sha256/Sha256Hasher.jvmAndroid.kt b/quartz/src/jvmAndroid/kotlin/com/vitorpamplona/quartz/utils/sha256/Sha256Hasher.jvmAndroid.kt index aabd5ab00..04354963f 100644 --- a/quartz/src/jvmAndroid/kotlin/com/vitorpamplona/quartz/utils/sha256/Sha256Hasher.jvmAndroid.kt +++ b/quartz/src/jvmAndroid/kotlin/com/vitorpamplona/quartz/utils/sha256/Sha256Hasher.jvmAndroid.kt @@ -37,12 +37,12 @@ class Sha256Hasher { * This avoids loading the entire input into memory at once. * * @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 */ fun hashStream( inputStream: InputStream, - bufferSize: Int = 65536, + bufferSize: Int = 8192, ): ByteArray { val buffer = ByteArray(bufferSize) try { diff --git a/quartz/src/jvmAndroid/kotlin/com/vitorpamplona/quartz/utils/sha256/Sha256Pool.jvmAndroid.kt b/quartz/src/jvmAndroid/kotlin/com/vitorpamplona/quartz/utils/sha256/Sha256Pool.jvmAndroid.kt index 86cd0dbf9..8efa3c65c 100644 --- a/quartz/src/jvmAndroid/kotlin/com/vitorpamplona/quartz/utils/sha256/Sha256Pool.jvmAndroid.kt +++ b/quartz/src/jvmAndroid/kotlin/com/vitorpamplona/quartz/utils/sha256/Sha256Pool.jvmAndroid.kt @@ -61,12 +61,12 @@ class Sha256Pool( * This avoids loading the entire input into memory at once. * * @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 */ fun hashStream( inputStream: InputStream, - bufferSize: Int = 65536, + bufferSize: Int = 8192, ): ByteArray { val hasher = acquire() try {