mirror of
https://github.com/pomerium/pomerium.git
synced 2025-08-02 00:10:45 +02:00
* update config file paths hash * update filemgr * use xxh3 for hashutil.Hash * update hashutil digest, fix trace buffer test * update comments * update namegen, go mod tidy
18 lines
512 B
Go
18 lines
512 B
Go
package filemgr
|
|
|
|
import (
|
|
"fmt"
|
|
"path/filepath"
|
|
|
|
"github.com/martinlindhe/base36"
|
|
"github.com/zeebo/xxh3"
|
|
)
|
|
|
|
// GetFileNameWithBytesHash constructs a filename using a base filename and a hash of
|
|
// the data. For example: GetFileNameWithBytesHash("example.txt", []byte{...}) ==> "example-abcd1234.txt"
|
|
func GetFileNameWithBytesHash(base string, data []byte) string {
|
|
h := xxh3.Hash(data)
|
|
he := base36.Encode(h)
|
|
ext := filepath.Ext(base)
|
|
return fmt.Sprintf("%s-%x%s", base[:len(base)-len(ext)], he, ext)
|
|
}
|