forked from jriou/coller
feat: Rename password by encryption key
Signed-off-by: Julien Riou <julien@riou.xyz>
This commit is contained in:
parent
634326190c
commit
8e1dd686d3
16 changed files with 118 additions and 117 deletions
|
@ -122,7 +122,7 @@ func (d *Database) Get(id string) (*Note, error) {
|
|||
return nil, nil
|
||||
}
|
||||
|
||||
func (d *Database) Create(content []byte, password string, encrypted bool, expiration int, deleteAfterRead bool, language string) (note *Note, err error) {
|
||||
func (d *Database) Create(content []byte, encryptionKey string, encrypted bool, expiration int, deleteAfterRead bool, language string) (note *Note, err error) {
|
||||
if expiration == 0 {
|
||||
expiration = d.expiration
|
||||
}
|
||||
|
@ -148,11 +148,11 @@ func (d *Database) Create(content []byte, password string, encrypted bool, expir
|
|||
DeleteAfterRead: deleteAfterRead,
|
||||
Language: language,
|
||||
}
|
||||
if password != "" {
|
||||
if err = internal.ValidatePassword(password); err != nil {
|
||||
if encryptionKey != "" {
|
||||
if err = internal.ValidateEncryptionKey(encryptionKey); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
note.Content, err = internal.Encrypt(note.Content, password)
|
||||
note.Content, err = internal.Encrypt(note.Content, encryptionKey)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue