1
0
Fork 0
forked from jriou/coller

feat: Rename password by encryption key

Signed-off-by: Julien Riou <julien@riou.xyz>
This commit is contained in:
Julien Riou 2025-09-24 07:09:01 +02:00
commit 8e1dd686d3
Signed by: jriou
GPG key ID: 9A099EDA51316854
16 changed files with 118 additions and 117 deletions

View file

@ -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
}