summaryrefslogtreecommitdiff
path: root/pkg/btrfs/crc32c.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/btrfs/crc32c.go')
-rw-r--r--pkg/btrfs/crc32c.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/pkg/btrfs/crc32c.go b/pkg/btrfs/crc32c.go
new file mode 100644
index 0000000..4ea4169
--- /dev/null
+++ b/pkg/btrfs/crc32c.go
@@ -0,0 +1,16 @@
+package btrfs
+
+import (
+ "encoding/binary"
+ "hash/crc32"
+)
+
+type CSum [0x20]byte
+
+func CRC32c(data []byte) CSum {
+ crc := crc32.Update(0, crc32.MakeTable(crc32.Castagnoli), data)
+
+ var ret CSum
+ binary.LittleEndian.PutUint32(ret[:], crc)
+ return ret
+}