10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
# File 'lib/sym/app/commands/show_examples.rb', line 10
def execute
output = []
output << example(comment: 'generate a new private key into an environment variable:',
command: 'export mykey=$(sym -g)',
echo: 'echo $mykey',
result: '75ngenJpB6zL47/8Wo7Ne6JN1pnOsqNEcIqblItpfg4='.green)
output << example(comment: 'generate a new key with a cached password & save to the default key file',
command: 'sym -gcpqo ' + Sym.default_key_file,
echo: 'New Password : ' + '••••••••••'.green,
result: 'Confirm Password : ' + '••••••••••'.green)
output << example(comment: 'encrypt a plain text string with default key file, and immediately decrypt it',
command: 'sym -es ' + '"secret string"'.bold.yellow + ' | sym -d',
result: 'secret string'.green)
output << example(comment: 'encrypt secrets file using key in the environment, and --negate option:',
command: 'export PRIVATE_KEY="75ngenJpB6zL47/8Wo7Ne6JN1pnOsqNEcIqblItpfg4="',
echo: 'sym -ck PRIVATE_KEY -n secrets.yml',
result: ''.green)
output << example(comment: 'encrypt a secrets file using the key in the keychain:',
command: 'sym -gqx keychain.key',
echo: 'sym -ck keychain.key -n secrets.yml',
result: 'secret string'.green)
output << example(comment: 'encrypt/decrypt sym.yml using the default key file',
command: 'sym -gcq > ' + Sym.default_key_file,
echo: 'sym -n secrets.yml',
result: 'sym -df secrets.yml.enc',
)
output << example(comment: 'decrypt an encrypted file and print it to STDOUT:',
command: 'sym -ck production.key -df secrets.yml.enc')
output << example(comment: 'edit an encrypted file in $EDITOR, use default key file, create file backup',
command: 'sym -tbf secrets.enc',
result: '
Private Key: ••••••••••••••••••••••••••••••••••••••••••••
Saved encrypted content to sym.enc.
Diff:
3c3
'.white.dark + '# (c) 2015 Konstantin Gredeskoul. All rights reserved.'.red.bold + '
---' + '
# (c) 2016 Konstantin Gredeskoul. All rights reserved.'.green.bold)
if Sym::App.is_osx?
output << example(comment: 'generate a new password-encrypted key, save it to your Keychain:',
command: 'sym -gpcx staging.key')
output << example(comment: 'use the new key to encrypt a file:',
command: 'sym -e -c -k staging.key -n etc/passwords.enc')
output << example(comment: 'use the new key to inline-edit the encrypted file:',
command: 'sym -k mykey -tf sym.yml.enc')
end
output.flatten.compact.join("\n")
end
|