Skip to content

Commit 3dfae01

Browse files
authored
feat(rt): add CRC32C algorithm (#724)
1 parent a5de65e commit 3dfae01

File tree

6 files changed

+775
-11
lines changed

6 files changed

+775
-11
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"id": "f01f5a37-e7ca-4786-a0a9-fd1ed6adf127",
3+
"type": "feature",
4+
"description": "Add CRC32C hashing algorithm",
5+
"issues": "awslabs/aws-sdk-kotlin/#727"
6+
}

runtime/hashing/common/src/aws/smithy/kotlin/runtime/hashing/Crc32.kt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,17 @@ public abstract class Crc32Base : HashFunction {
1212
override val digestSizeBytes: Int = 4
1313

1414
public abstract fun digestValue(): UInt
15+
16+
override fun digest(): ByteArray {
17+
val x = digestValue()
18+
reset()
19+
return byteArrayOf(
20+
((x shr 24) and 0xffu).toByte(),
21+
((x shr 16) and 0xffu).toByte(),
22+
((x shr 8) and 0xffu).toByte(),
23+
(x and 0xffu).toByte(),
24+
)
25+
}
1526
}
1627

1728
/**

0 commit comments

Comments
 (0)