aboutsummaryrefslogtreecommitdiff
path: root/internal/utils
diff options
context:
space:
mode:
authorishaan <contact@ishaan.cc>2026-07-19 18:33:40 +0530
committerishaan <contact@ishaan.cc>2026-07-19 18:33:40 +0530
commite48a02646f60b6fdff8db5c4105896756584ac63 (patch)
tree3371785e68bfe6b14065589ba7fd417d75742595 /internal/utils
parentd6449a232e6bd9eb46132c7403a05ac1a756b619 (diff)
reorganize
Diffstat (limited to 'internal/utils')
-rw-r--r--internal/utils/utils.go24
1 files changed, 1 insertions, 23 deletions
diff --git a/internal/utils/utils.go b/internal/utils/utils.go
index cea00a3..329128a 100644
--- a/internal/utils/utils.go
+++ b/internal/utils/utils.go
@@ -5,7 +5,6 @@ import (
"fmt"
"os"
"os/signal"
- "strconv"
"syscall"
"github.com/charmbracelet/x/term"
@@ -72,28 +71,7 @@ func CheckFileAuthMode(notePath string) (crypt.AuthMode, error) {
return "", fmt.Errorf("failed to read file: %w", err)
}
- idx := -1
- for i, b := range data {
- if b == ':' {
- idx = i
- break
- }
- }
- if idx == -1 {
- return "", fmt.Errorf("invalid file format: no header length prefix found")
- }
-
- headerLen, err := strconv.Atoi(string(data[:idx]))
- if err != nil {
- return "", fmt.Errorf("failed to parse header length: %w", err)
- }
-
- if headerLen < 0 || idx+1+headerLen > len(data) {
- return "", fmt.Errorf("invalid header length %d", headerLen)
- }
-
- headerBytes := data[idx+1 : idx+1+headerLen]
- headers, err := crypt.GetFileHeaders(headerBytes)
+ headers, _, err := crypt.ParseFileHeaders(data)
if err != nil {
return "", fmt.Errorf("failed to decode headers: %w", err)
}