diff options
Diffstat (limited to 'internal/nametransform')
-rw-r--r-- | internal/nametransform/diriv.go | 4 | ||||
-rw-r--r-- | internal/nametransform/longnames.go | 5 |
2 files changed, 4 insertions, 5 deletions
diff --git a/internal/nametransform/diriv.go b/internal/nametransform/diriv.go index cd96cfb..e4670c8 100644 --- a/internal/nametransform/diriv.go +++ b/internal/nametransform/diriv.go @@ -97,7 +97,7 @@ func (be *NameTransform) EncryptPathDirIV(plainPath string, rootDir string) (cip if iv != nil { cBaseName := be.EncryptName(baseName, iv) if be.longNames && len(cBaseName) > syscall.NAME_MAX { - cBaseName = HashLongName(cBaseName) + cBaseName = be.HashLongName(cBaseName) } cipherPath = filepath.Join(cParentDir, cBaseName) return cipherPath, nil @@ -113,7 +113,7 @@ func (be *NameTransform) EncryptPathDirIV(plainPath string, rootDir string) (cip } encryptedName := be.EncryptName(plainName, iv) if be.longNames && len(encryptedName) > syscall.NAME_MAX { - encryptedName = HashLongName(encryptedName) + encryptedName = be.HashLongName(encryptedName) } encryptedNames = append(encryptedNames, encryptedName) wd = filepath.Join(wd, encryptedName) diff --git a/internal/nametransform/longnames.go b/internal/nametransform/longnames.go index 71a4c16..f9ba848 100644 --- a/internal/nametransform/longnames.go +++ b/internal/nametransform/longnames.go @@ -2,7 +2,6 @@ package nametransform import ( "crypto/sha256" - "encoding/base64" "io/ioutil" "os" "path/filepath" @@ -24,9 +23,9 @@ const ( // HashLongName - take the hash of a long string "name" and return // "gocryptfs.longname.[sha256]" -func HashLongName(name string) string { +func (n *NameTransform) HashLongName(name string) string { hashBin := sha256.Sum256([]byte(name)) - hashBase64 := base64.URLEncoding.EncodeToString(hashBin[:]) + hashBase64 := n.b64.EncodeToString(hashBin[:]) return longNamePrefix + hashBase64 } |