MCPcopy
hub / github.com/getsops/sops / File

Function File

decrypt/decrypt.go:20–30  ·  view source on GitHub ↗

File is a wrapper around Data that reads a local encrypted file and returns its cleartext data in an []byte

(path, format string)

Source from the content-addressed store, hash-verified

18// File is a wrapper around Data that reads a local encrypted
19// file and returns its cleartext data in an []byte
20func File(path, format string) (cleartext []byte, err error) {
21 // Read the file into an []byte
22 encryptedData, err := os.ReadFile(path)
23 if err != nil {
24 return nil, fmt.Errorf("Failed to read %q: %w", path, err)
25 }
26
27 // uses same logic as cli.
28 formatFmt := FormatForPathOrString(path, format)
29 return DataWithFormat(encryptedData, formatFmt)
30}
31
32// DataWithFormat is a helper that takes encrypted data, and a format enum value,
33// decrypts the data and returns its cleartext in an []byte.

Callers 1

ExampleFileFunction · 0.85

Calls 2

FormatForPathOrStringFunction · 0.85
DataWithFormatFunction · 0.85

Tested by 1

ExampleFileFunction · 0.68