MCPcopy Create free account
hub / github.com/Driver-C/tryssh / executeEncrypt

Function executeEncrypt

cmd/encrypt/encrypt.go:94–116  ·  view source on GitHub ↗

executeEncrypt loads the config, encrypts plaintext passwords, and writes back.

()

Source from the content-addressed store, hash-verified

92
93// executeEncrypt loads the config, encrypts plaintext passwords, and writes back.
94func executeEncrypt() {
95 configuration, err := config.LoadConfig()
96 if err != nil {
97 fatalFn(err)
98 return
99 }
100
101 count := countPlaintextPasswords(configuration)
102 if count == 0 {
103 fmt.Println("No passwords to encrypt")
104 utils.ClearMasterKey()
105 return
106 }
107
108 if err := config.UpdateConfig(configuration); err != nil {
109 fatalFn("Failed to write encrypted config:", err)
110 return
111 }
112
113 utils.ClearMasterKey()
114 fmt.Printf("Encrypted %d password(s) successfully\n", count)
115 fmt.Println("Remember your master password — it cannot be recovered if lost")
116}
117
118// countPlaintextPasswords counts password fields that are non-empty and not yet encrypted.
119func countPlaintextPasswords(c *config.MainConfig) int {

Calls 4

LoadConfigFunction · 0.92
ClearMasterKeyFunction · 0.92
UpdateConfigFunction · 0.92
countPlaintextPasswordsFunction · 0.85