summaryrefslogtreecommitdiff
path: root/vendor/codeberg.org/gruf/go-hashenc
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2022-05-08 19:49:45 +0200
committerLibravatar GitHub <noreply@github.com>2022-05-08 18:49:45 +0100
commit5004e0a9da665ccc0e18cd4075ee636641b71f0a (patch)
treeb7c8269b954ced61afa9fffd7305bd88acca6f8e /vendor/codeberg.org/gruf/go-hashenc
parent[bugfix] Fix existing bio text showing as HTML (#531) (diff)
downloadgotosocial-5004e0a9da665ccc0e18cd4075ee636641b71f0a.tar.xz
[bugfix] Fix remote media pruning failing if media already gone (#548)
* fix error check of prune to allow missing files * update go-store library, add test for pruning item with db entry but no file Signed-off-by: kim <grufwub@gmail.com> * remove now-unneccessary error check Signed-off-by: kim <grufwub@gmail.com> Co-authored-by: kim <grufwub@gmail.com>
Diffstat (limited to 'vendor/codeberg.org/gruf/go-hashenc')
-rw-r--r--vendor/codeberg.org/gruf/go-hashenc/enc.go10
-rw-r--r--vendor/codeberg.org/gruf/go-hashenc/hash.go136
-rw-r--r--vendor/codeberg.org/gruf/go-hashenc/hashenc.go4
3 files changed, 7 insertions, 143 deletions
diff --git a/vendor/codeberg.org/gruf/go-hashenc/enc.go b/vendor/codeberg.org/gruf/go-hashenc/enc.go
index 39b342843..0cc8d5986 100644
--- a/vendor/codeberg.org/gruf/go-hashenc/enc.go
+++ b/vendor/codeberg.org/gruf/go-hashenc/enc.go
@@ -6,7 +6,7 @@ import (
"encoding/hex"
)
-// Encoder defines an interface for encoding binary data
+// Encoder defines an interface for encoding binary data.
type Encoder interface {
// Encode encodes the data at src into dst
Encode(dst []byte, src []byte)
@@ -15,22 +15,22 @@ type Encoder interface {
EncodedLen(int) int
}
-// Base32 returns a new base32 Encoder
+// Base32 returns a new base32 Encoder (StdEncoding, no padding).
func Base32() Encoder {
return base32.StdEncoding.WithPadding(base64.NoPadding)
}
-// Base64 returns a new base64 Encoder
+// Base64 returns a new base64 Encoder (URLEncoding, no padding).
func Base64() Encoder {
return base64.URLEncoding.WithPadding(base64.NoPadding)
}
-// Hex returns a new hex Encoder
+// Hex returns a new hex Encoder.
func Hex() Encoder {
return &hexEncoder{}
}
-// hexEncoder simply provides an empty receiver to satisfy Encoder
+// hexEncoder simply provides an empty receiver to satisfy Encoder.
type hexEncoder struct{}
func (*hexEncoder) Encode(dst []byte, src []byte) {
diff --git a/vendor/codeberg.org/gruf/go-hashenc/hash.go b/vendor/codeberg.org/gruf/go-hashenc/hash.go
deleted file mode 100644
index d291fa2f2..000000000
--- a/vendor/codeberg.org/gruf/go-hashenc/hash.go
+++ /dev/null
@@ -1,136 +0,0 @@
-package hashenc
-
-import (
- "crypto/md5"
- "crypto/sha1"
- "crypto/sha256"
- "crypto/sha512"
- "hash"
- "sync"
-)
-
-// Hash defines a pooled hash.Hash implementation
-type Hash interface {
- // Hash ensures we implement the base hash.Hash implementation
- hash.Hash
-
- // Release resets the Hash and places it back in the pool
- Release()
-}
-
-// poolHash is our Hash implementation, providing a hash.Hash and a pool to return to
-type poolHash struct {
- hash.Hash
- pool *sync.Pool
-}
-
-func (h *poolHash) Release() {
- h.Reset()
- h.pool.Put(h)
-}
-
-// SHA512Pool defines a pool of SHA512 hashes
-type SHA512Pool interface {
- // SHA512 returns a Hash implementing the SHA512 hashing algorithm
- SHA512() Hash
-}
-
-// NewSHA512Pool returns a new SHA512Pool implementation
-func NewSHA512Pool() SHA512Pool {
- p := &sha512Pool{}
- p.New = func() interface{} {
- return &poolHash{
- Hash: sha512.New(),
- pool: &p.Pool,
- }
- }
- return p
-}
-
-// sha512Pool is our SHA512Pool implementation, simply wrapping sync.Pool
-type sha512Pool struct {
- sync.Pool
-}
-
-func (p *sha512Pool) SHA512() Hash {
- return p.Get().(Hash)
-}
-
-// SHA256Pool defines a pool of SHA256 hashes
-type SHA256Pool interface {
- // SHA256 returns a Hash implementing the SHA256 hashing algorithm
- SHA256() Hash
-}
-
-// NewSHA256Pool returns a new SHA256Pool implementation
-func NewSHA256Pool() SHA256Pool {
- p := &sha256Pool{}
- p.New = func() interface{} {
- return &poolHash{
- Hash: sha256.New(),
- pool: &p.Pool,
- }
- }
- return p
-}
-
-// sha256Pool is our SHA256Pool implementation, simply wrapping sync.Pool
-type sha256Pool struct {
- sync.Pool
-}
-
-func (p *sha256Pool) SHA256() Hash {
- return p.Get().(Hash)
-}
-
-// SHA1Pool defines a pool of SHA1 hashes
-type SHA1Pool interface {
- SHA1() Hash
-}
-
-// NewSHA1Pool returns a new SHA1Pool implementation
-func NewSHA1Pool() SHA1Pool {
- p := &sha1Pool{}
- p.New = func() interface{} {
- return &poolHash{
- Hash: sha1.New(),
- pool: &p.Pool,
- }
- }
- return p
-}
-
-// sha1Pool is our SHA1Pool implementation, simply wrapping sync.Pool
-type sha1Pool struct {
- sync.Pool
-}
-
-func (p *sha1Pool) SHA1() Hash {
- return p.Get().(Hash)
-}
-
-// MD5Pool defines a pool of MD5 hashes
-type MD5Pool interface {
- MD5() Hash
-}
-
-// NewMD5Pool returns a new MD5 implementation
-func NewMD5Pool() MD5Pool {
- p := &md5Pool{}
- p.New = func() interface{} {
- return &poolHash{
- Hash: md5.New(),
- pool: &p.Pool,
- }
- }
- return p
-}
-
-// md5Pool is our MD5Pool implementation, simply wrapping sync.Pool
-type md5Pool struct {
- sync.Pool
-}
-
-func (p *md5Pool) MD5() Hash {
- return p.Get().(Hash)
-}
diff --git a/vendor/codeberg.org/gruf/go-hashenc/hashenc.go b/vendor/codeberg.org/gruf/go-hashenc/hashenc.go
index 66fc0a92c..fc110c533 100644
--- a/vendor/codeberg.org/gruf/go-hashenc/hashenc.go
+++ b/vendor/codeberg.org/gruf/go-hashenc/hashenc.go
@@ -18,7 +18,7 @@ type HashEncoder interface {
Size() int
}
-// New returns a new HashEncoder instance based on supplied hash.Hash and Encoder supplying functions
+// 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{
@@ -29,7 +29,7 @@ func New(hash hash.Hash, enc Encoder) HashEncoder {
}
}
-// henc is the HashEncoder implementation
+// henc is the HashEncoder implementation.
type henc struct {
hash hash.Hash
hbuf []byte