ReadPasswordFromFile reads and returns the password from the given filename. The contents of the file will be trimmed at the right.
(filename string)
| 53 | // ReadPasswordFromFile reads and returns the password from the given filename. |
| 54 | // The contents of the file will be trimmed at the right. |
| 55 | func ReadPasswordFromFile(filename string) ([]byte, error) { |
| 56 | password, err := os.ReadFile(filename) // #nosec G703 -- file intended to be provided by user |
| 57 | if err != nil { |
| 58 | return nil, errs.FileError(err, filename) |
| 59 | } |
| 60 | password = bytes.TrimRightFunc(password, unicode.IsSpace) |
| 61 | return password, nil |
| 62 | } |
| 63 | |
| 64 | // ReadStringPasswordFromFile reads and returns the password from the given filename. |
| 65 | // The contents of the file will be trimmed at the right. |
no outgoing calls
searching dependent graphs…