diff options
author | 2023-10-31 11:12:22 +0000 | |
---|---|---|
committer | 2023-10-31 11:12:22 +0000 | |
commit | ce71a5a7902963538fc54583588850563f6746cc (patch) | |
tree | 3e869eba6d25d2db5fe81184ffee595e451b3147 /vendor/codeberg.org/gruf/go-hashenc | |
parent | [bugfix] Relax `Mention` parsing, allowing either href or name (#2320) (diff) | |
download | gotosocial-ce71a5a7902963538fc54583588850563f6746cc.tar.xz |
[feature] add per-uri dereferencer locks (#2291)
Diffstat (limited to 'vendor/codeberg.org/gruf/go-hashenc')
-rw-r--r-- | vendor/codeberg.org/gruf/go-hashenc/LICENSE | 9 | ||||
-rw-r--r-- | vendor/codeberg.org/gruf/go-hashenc/README.md | 1 | ||||
-rw-r--r-- | vendor/codeberg.org/gruf/go-hashenc/enc.go | 42 | ||||
-rw-r--r-- | vendor/codeberg.org/gruf/go-hashenc/hashenc.go | 58 |
4 files changed, 0 insertions, 110 deletions
diff --git a/vendor/codeberg.org/gruf/go-hashenc/LICENSE b/vendor/codeberg.org/gruf/go-hashenc/LICENSE deleted file mode 100644 index b7c4417ac..000000000 --- a/vendor/codeberg.org/gruf/go-hashenc/LICENSE +++ /dev/null @@ -1,9 +0,0 @@ -MIT License - -Copyright (c) 2021 gruf - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/codeberg.org/gruf/go-hashenc/README.md b/vendor/codeberg.org/gruf/go-hashenc/README.md deleted file mode 100644 index e885d0bb2..000000000 --- a/vendor/codeberg.org/gruf/go-hashenc/README.md +++ /dev/null @@ -1 +0,0 @@ -HashEncoder provides a means of quickly hash-summing and encoding data
\ No newline at end of file diff --git a/vendor/codeberg.org/gruf/go-hashenc/enc.go b/vendor/codeberg.org/gruf/go-hashenc/enc.go deleted file mode 100644 index 0cc8d5986..000000000 --- a/vendor/codeberg.org/gruf/go-hashenc/enc.go +++ /dev/null @@ -1,42 +0,0 @@ -package hashenc - -import ( - "encoding/base32" - "encoding/base64" - "encoding/hex" -) - -// Encoder defines an interface for encoding binary data. -type Encoder interface { - // Encode encodes the data at src into dst - Encode(dst []byte, src []byte) - - // EncodedLen returns the encoded length for input data of supplied length - EncodedLen(int) int -} - -// Base32 returns a new base32 Encoder (StdEncoding, no padding). -func Base32() Encoder { - return base32.StdEncoding.WithPadding(base64.NoPadding) -} - -// Base64 returns a new base64 Encoder (URLEncoding, no padding). -func Base64() Encoder { - return base64.URLEncoding.WithPadding(base64.NoPadding) -} - -// Hex returns a new hex Encoder. -func Hex() Encoder { - return &hexEncoder{} -} - -// hexEncoder simply provides an empty receiver to satisfy Encoder. -type hexEncoder struct{} - -func (*hexEncoder) Encode(dst []byte, src []byte) { - hex.Encode(dst, src) -} - -func (*hexEncoder) EncodedLen(len int) int { - return hex.EncodedLen(len) -} diff --git a/vendor/codeberg.org/gruf/go-hashenc/hashenc.go b/vendor/codeberg.org/gruf/go-hashenc/hashenc.go deleted file mode 100644 index fc110c533..000000000 --- a/vendor/codeberg.org/gruf/go-hashenc/hashenc.go +++ /dev/null @@ -1,58 +0,0 @@ -package hashenc - -import ( - "hash" - - "codeberg.org/gruf/go-bytes" -) - -// HashEncoder defines an interface for calculating encoded hash sums of binary data -type HashEncoder interface { - // EncodeSum calculates the hash sum of src and encodes (at most) Size() into dst - EncodeSum(dst []byte, src []byte) - - // EncodedSum calculates the encoded hash sum of src and returns data in a newly allocated bytes.Bytes - EncodedSum(src []byte) bytes.Bytes - - // Size returns the expected length of encoded hashes - Size() int -} - -// New returns a new HashEncoder instance based on supplied hash.Hash and Encoder supplying functions. -func New(hash hash.Hash, enc Encoder) HashEncoder { - hashSize := hash.Size() - return &henc{ - hash: hash, - hbuf: make([]byte, hashSize), - enc: enc, - size: enc.EncodedLen(hashSize), - } -} - -// henc is the HashEncoder implementation. -type henc struct { - hash hash.Hash - hbuf []byte - enc Encoder - size int -} - -func (henc *henc) EncodeSum(dst []byte, src []byte) { - // Hash supplied bytes - henc.hash.Reset() - henc.hash.Write(src) - henc.hbuf = henc.hash.Sum(henc.hbuf[:0]) - - // Encode the hashsum and return a copy - henc.enc.Encode(dst, henc.hbuf) -} - -func (henc *henc) EncodedSum(src []byte) bytes.Bytes { - dst := make([]byte, henc.size) - henc.EncodeSum(dst, src) - return bytes.ToBytes(dst) -} - -func (henc *henc) Size() int { - return henc.size -} |