MCPcopy Index your code
hub / github.com/rclone/rclone / newCipherForConfig

Function newCipherForConfig

backend/crypt/crypt.go:180–210  ·  view source on GitHub ↗

newCipherForConfig constructs a Cipher for the given config name

(opt *Options)

Source from the content-addressed store, hash-verified

178
179// newCipherForConfig constructs a Cipher for the given config name
180func newCipherForConfig(opt *Options) (*Cipher, error) {
181 mode, err := NewNameEncryptionMode(opt.FilenameEncryption)
182 if err != nil {
183 return nil, err
184 }
185 if opt.Password == "" {
186 return nil, errors.New("password not set in config file")
187 }
188 password, err := obscure.Reveal(opt.Password)
189 if err != nil {
190 return nil, fmt.Errorf("failed to decrypt password: %w", err)
191 }
192 var salt string
193 if opt.Password2 != "" {
194 salt, err = obscure.Reveal(opt.Password2)
195 if err != nil {
196 return nil, fmt.Errorf("failed to decrypt password2: %w", err)
197 }
198 }
199 enc, err := NewNameEncoding(opt.FilenameEncoding)
200 if err != nil {
201 return nil, err
202 }
203 cipher, err := newCipher(mode, password, salt, opt.DirectoryNameEncryption, enc)
204 if err != nil {
205 return nil, fmt.Errorf("failed to make cipher: %w", err)
206 }
207 cipher.setEncryptedSuffix(opt.Suffix)
208 cipher.setPassBadBlocks(opt.PassBadBlocks)
209 return cipher, nil
210}
211
212// NewCipher constructs a Cipher for the given config
213func NewCipher(m configmap.Mapper) (*Cipher, error) {

Callers 2

NewCipherFunction · 0.85
NewFsFunction · 0.85

Calls 7

RevealFunction · 0.92
NewNameEncryptionModeFunction · 0.85
NewNameEncodingFunction · 0.85
newCipherFunction · 0.85
setEncryptedSuffixMethod · 0.80
setPassBadBlocksMethod · 0.80
ErrorfMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…