newCipher initialises the cipher. If salt is "" then it uses a built in salt val
(mode NameEncryptionMode, password, salt string, dirNameEncrypt bool, enc fileNameEncoding)
| 185 | |
| 186 | // newCipher initialises the cipher. If salt is "" then it uses a built in salt val |
| 187 | func newCipher(mode NameEncryptionMode, password, salt string, dirNameEncrypt bool, enc fileNameEncoding) (*Cipher, error) { |
| 188 | c := &Cipher{ |
| 189 | mode: mode, |
| 190 | fileNameEnc: enc, |
| 191 | cryptoRand: rand.Reader, |
| 192 | dirNameEncrypt: dirNameEncrypt, |
| 193 | encryptedSuffix: ".bin", |
| 194 | } |
| 195 | c.buffers.New = func() any { |
| 196 | return new([blockSize]byte) |
| 197 | } |
| 198 | err := c.Key(password, salt) |
| 199 | if err != nil { |
| 200 | return nil, err |
| 201 | } |
| 202 | return c, nil |
| 203 | } |
| 204 | |
| 205 | // setEncryptedSuffix set suffix, or an empty string |
| 206 | func (c *Cipher) setEncryptedSuffix(suffix string) { |
searching dependent graphs…