Skip to content

Commit

Permalink
Fixed long time bug on settings ecryption using old option "password"…
Browse files Browse the repository at this point in the history
… instead of "key".
  • Loading branch information
igoramadas committed Sep 30, 2016
1 parent 5ffd62a commit e65ed8a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
9 changes: 2 additions & 7 deletions lib/settings.coffee
Expand Up @@ -106,11 +106,6 @@ class Settings
options = {} if not options?
options = lodash.defaults options, {cipher: "aes256", key: env["EXPRESSER_SETTINGS_CRYPTOKEY"]}
options.key = "ExpresserSettings" if not options.key? or options.key is ""

# Option 'password' is deprecated, now replaced by 'key'.
if options.password? and not options.key?
console.warn "Settings.cryptoHelper", "Option 'password'' is deprecated, please use 'key' to set the encryption key."

settingsJson = @loadFromJson filename, false

# Settings file not found or invalid? Stop here.
Expand Down Expand Up @@ -147,7 +142,7 @@ class Settings
newValue = "string:"

# Create cipher amd encrypt data.
c = crypto.createCipher options.cipher, options.password
c = crypto.createCipher options.cipher, options.key
newValue += c.update currentValue.toString(), @general.encoding, "hex"
newValue += c.final "hex"

Expand All @@ -158,7 +153,7 @@ class Settings
newValue = ""

# Create cipher and decrypt.
c = crypto.createDecipher options.cipher, options.password
c = crypto.createDecipher options.cipher, options.key
newValue += c.update arrValue[1], "hex", @general.encoding
newValue += c.final @general.encoding

Expand Down
2 changes: 1 addition & 1 deletion test/settings.js
Expand Up @@ -86,7 +86,7 @@ describe("Settings Tests", function() {
if (!encrypted.encrypted) {
return callback("Property 'encrypted' was not properly set.")
} else if (encrypted.app.title == "Expresser Settings Encryption") {
return callback("Encryption failed, settings.general.appTitle is still set as 'Expresser'.")
return callback("Encryption failed, settings.app.title is still set as 'Expresser'.")
}

settings.decrypt(filename);
Expand Down

0 comments on commit e65ed8a

Please sign in to comment.