Skip to content

Commit 5ea9422

Browse files
committed
Removed detailed errors from stderr reporting by default.
1 parent 51c7269 commit 5ea9422

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

README.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,11 @@ CfgCrypt or config crypt is a cli tool to encrypt values in a text configuration
44

55
## Concept
66

7-
The basic idea is that you write your configuration file in whatever text format you prefer. Then you run cfgcrypt on the file to encrypt the variables you want hidden. From there your application base 64 decodes the encrypted text, and runs AES 128 decryption, in CBC mode, with PKCS7 padding, using the key from the generated key file. The iv for the decryption is included in the first set of bytes.
8-
9-
So that cfgcrypt knows what to encrypt you must give it a prefix and a postfix string that will delimit the values that you wish to encrypt. These values will be encrypted in-place. If an encryption key is not passed to the utility then one will be randomly generated and placed next to the encrypted file with 0600 file permissions and a ".key" file extension pre-pended to the original file's name.
7+
Write your configuration file in whatever text format you prefer, then wrap any values that you would like to keep secret in prefix and postfix delimiters that occur no where else in your file. Then you run cfgcrypt with your delimiters on the file to encrypt the variables you want hidden. From there your application decodes the secret values using the configuration file and a key file.
108

119
## Decryption logic
1210

13-
Pseudo-code example of decryption process:
11+
Pseudo-code example of decryption process for CBC encryption:
1412

1513
```
1614
configData = io.ReadConfigFile(fileName)
@@ -52,5 +50,4 @@ godep go build
5250
## Future development
5351

5452
I'm considering the following upgrades:
55-
- Support for more encryption modes/algorithms
56-
- Safer error messages to avoid leaking any security details (not certain if necessary)
53+
- Support for more encryption modes/algorithms

main.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ func main() {
2020
prefix := cli.String("prefix", "#{{", "Prefix string denoting start of value to be encrypted")
2121
postfix := cli.String("postfix", "}}#", "Post string denoting end of value to be encrypted")
2222
force := cli.Bool("force", false, "Overwrite key file if found")
23+
debug := cli.Bool("debug", false, "Display detailed error messages")
2324
if len(os.Args) < 2 {
2425
os.Stderr.WriteString("Not enough arguments\n")
2526
explainUsage(cli)
@@ -36,7 +37,12 @@ func main() {
3637
}
3738
err := textValueEncryptor.EncryptTextFile(textfile, *prefix, *postfix, *encodedKey, *force)
3839
if err != nil {
39-
msg := fmt.Sprintf("Error encrypting file \"%s\":\n%s\n", textfile, err.Error())
40+
var msg string
41+
if debug != nil && *debug == true {
42+
msg = fmt.Sprintf("Error encrypting file \"%s\":\n%s\n", textfile, err.Error())
43+
} else {
44+
msg = fmt.Sprintf("Error encrypting file \"%s\" For more details enable debug mode.\n", textfile)
45+
}
4046
os.Stderr.WriteString(msg)
4147
os.Exit(1)
4248
}

0 commit comments

Comments
 (0)