diff options
author | Manuel <manuel.coenen@gmail.com> | 2019-10-09 17:15:08 +0300 |
---|---|---|
committer | dc42 <dcrocker@eschertech.com> | 2019-10-09 17:15:08 +0300 |
commit | 66b6ffad261045799eb7f80a46040d8cbe00bbe9 (patch) | |
tree | 89c72f0a7770e9000d371a737310e48c33a9688c /Tools | |
parent | 598833d9508a9bf2c3c0633226bbb1f983871714 (diff) |
Add crc32appender source and precompiled binaries for Win and Linux x86_64 (#320)
Diffstat (limited to 'Tools')
-rw-r--r-- | Tools/crc32appender/crc32appender.go | 39 | ||||
-rwxr-xr-x | Tools/crc32appender/linux-x86_64/crc32appender | bin | 0 -> 1933324 bytes | |||
-rwxr-xr-x | Tools/crc32appender/win-x86_64/crc32appender.exe | bin | 0 -> 2043904 bytes |
3 files changed, 39 insertions, 0 deletions
diff --git a/Tools/crc32appender/crc32appender.go b/Tools/crc32appender/crc32appender.go new file mode 100644 index 00000000..668f5d00 --- /dev/null +++ b/Tools/crc32appender/crc32appender.go @@ -0,0 +1,39 @@ +package main + +import ( + "encoding/binary" + "hash/crc32" + "io/ioutil" + "os" +) + +func main() { + + // Loop through arguments + for _, f := range os.Args[1:] { + + // Read the file to memory and panic if it fails + b, err := ioutil.ReadFile(f) + if err != nil { + panic(err) + } + // Calculate CRC32 with IEEE polynomials + c := crc32.ChecksumIEEE(b) + + // Open the same file for appending and panic if it fails + f, err := os.OpenFile(f, os.O_APPEND|os.O_WRONLY, 0644) + if err != nil { + panic(err) + } + defer f.Close() + + // Create little-endian represenation of CRC32 sum + le := make([]byte, crc32.Size) + binary.LittleEndian.PutUint32(le, c) + + // Append the CRC32 and panic if it fails + if _, err = f.Write(le); err != nil { + panic(err) + } + } +} diff --git a/Tools/crc32appender/linux-x86_64/crc32appender b/Tools/crc32appender/linux-x86_64/crc32appender Binary files differnew file mode 100755 index 00000000..5c282dac --- /dev/null +++ b/Tools/crc32appender/linux-x86_64/crc32appender diff --git a/Tools/crc32appender/win-x86_64/crc32appender.exe b/Tools/crc32appender/win-x86_64/crc32appender.exe Binary files differnew file mode 100755 index 00000000..9dcdfef0 --- /dev/null +++ b/Tools/crc32appender/win-x86_64/crc32appender.exe |