MCPcopy Create free account
hub / github.com/devnullvoid/pvetui / EncryptSensitiveFields

Function EncryptSensitiveFields

internal/config/encryption.go:201–219  ·  view source on GitHub ↗

EncryptSensitiveFields encrypts all sensitive fields in a ProfileConfig. Fields that are already encrypted are left unchanged.

(profile *ProfileConfig)

Source from the content-addressed store, hash-verified

199// EncryptSensitiveFields encrypts all sensitive fields in a ProfileConfig.
200// Fields that are already encrypted are left unchanged.
201func EncryptSensitiveFields(profile *ProfileConfig) error {
202 var err error
203
204 if profile.Password != "" && !isEncrypted(profile.Password) {
205 profile.Password, err = EncryptField(profile.Password)
206 if err != nil {
207 return fmt.Errorf("encrypt password: %w", err)
208 }
209 }
210
211 if profile.TokenSecret != "" && !isEncrypted(profile.TokenSecret) {
212 profile.TokenSecret, err = EncryptField(profile.TokenSecret)
213 if err != nil {
214 return fmt.Errorf("encrypt token_secret: %w", err)
215 }
216 }
217
218 return nil
219}
220
221// DecryptSensitiveFields decrypts all sensitive fields in a ProfileConfig.
222// Fields that are not encrypted are left unchanged.

Callers 1

Calls 2

isEncryptedFunction · 0.85
EncryptFieldFunction · 0.85

Tested by

no test coverage detected