diff options
author | Alex Pilon <apilon@hashicorp.com> | 2019-02-22 18:24:37 -0500 |
---|---|---|
committer | Alex Pilon <apilon@hashicorp.com> | 2019-02-22 18:24:37 -0500 |
commit | 15c0b25d011f37e7c20aeca9eaf461f78285b8d9 (patch) | |
tree | 255c250a5c9d4801c74092d33b7337d8c14438ff /vendor/github.com/ulikunitz/xz/crc.go | |
parent | 07971ca38143c5faf951d152fba370ddcbe26ad5 (diff) | |
download | terraform-provider-statuscake-15c0b25d011f37e7c20aeca9eaf461f78285b8d9.tar.gz terraform-provider-statuscake-15c0b25d011f37e7c20aeca9eaf461f78285b8d9.tar.zst terraform-provider-statuscake-15c0b25d011f37e7c20aeca9eaf461f78285b8d9.zip |
deps: github.com/hashicorp/terraform@sdk-v0.11-with-go-modules
Updated via: go get github.com/hashicorp/terraform@sdk-v0.11-with-go-modules and go mod tidy
Diffstat (limited to 'vendor/github.com/ulikunitz/xz/crc.go')
-rw-r--r-- | vendor/github.com/ulikunitz/xz/crc.go | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/vendor/github.com/ulikunitz/xz/crc.go b/vendor/github.com/ulikunitz/xz/crc.go new file mode 100644 index 0000000..b44dca9 --- /dev/null +++ b/vendor/github.com/ulikunitz/xz/crc.go | |||
@@ -0,0 +1,54 @@ | |||
1 | // Copyright 2014-2017 Ulrich Kunitz. All rights reserved. | ||
2 | // Use of this source code is governed by a BSD-style | ||
3 | // license that can be found in the LICENSE file. | ||
4 | |||
5 | package xz | ||
6 | |||
7 | import ( | ||
8 | "hash" | ||
9 | "hash/crc32" | ||
10 | "hash/crc64" | ||
11 | ) | ||
12 | |||
13 | // crc32Hash implements the hash.Hash32 interface with Sum returning the | ||
14 | // crc32 value in little-endian encoding. | ||
15 | type crc32Hash struct { | ||
16 | hash.Hash32 | ||
17 | } | ||
18 | |||
19 | // Sum returns the crc32 value as little endian. | ||
20 | func (h crc32Hash) Sum(b []byte) []byte { | ||
21 | p := make([]byte, 4) | ||
22 | putUint32LE(p, h.Hash32.Sum32()) | ||
23 | b = append(b, p...) | ||
24 | return b | ||
25 | } | ||
26 | |||
27 | // newCRC32 returns a CRC-32 hash that returns the 64-bit value in | ||
28 | // little-endian encoding using the IEEE polynomial. | ||
29 | func newCRC32() hash.Hash { | ||
30 | return crc32Hash{Hash32: crc32.NewIEEE()} | ||
31 | } | ||
32 | |||
33 | // crc64Hash implements the Hash64 interface with Sum returning the | ||
34 | // CRC-64 value in little-endian encoding. | ||
35 | type crc64Hash struct { | ||
36 | hash.Hash64 | ||
37 | } | ||
38 | |||
39 | // Sum returns the CRC-64 value in little-endian encoding. | ||
40 | func (h crc64Hash) Sum(b []byte) []byte { | ||
41 | p := make([]byte, 8) | ||
42 | putUint64LE(p, h.Hash64.Sum64()) | ||
43 | b = append(b, p...) | ||
44 | return b | ||
45 | } | ||
46 | |||
47 | // crc64Table is used to create a CRC-64 hash. | ||
48 | var crc64Table = crc64.MakeTable(crc64.ECMA) | ||
49 | |||
50 | // newCRC64 returns a CRC-64 hash that returns the 64-bit value in | ||
51 | // little-endian encoding using the ECMA polynomial. | ||
52 | func newCRC64() hash.Hash { | ||
53 | return crc64Hash{Hash64: crc64.New(crc64Table)} | ||
54 | } | ||