|
|
@ -6,7 +6,7 @@ class EdgeEncryptor { |
|
|
|
encrypt (password, dataObject) { |
|
|
|
encrypt (password, dataObject) { |
|
|
|
|
|
|
|
|
|
|
|
var salt = this._generateSalt() |
|
|
|
var salt = this._generateSalt() |
|
|
|
return this.keyFromPassword(password, salt) |
|
|
|
return this._keyFromPassword(password, salt) |
|
|
|
.then(function (key) { |
|
|
|
.then(function (key) { |
|
|
|
|
|
|
|
|
|
|
|
var data = JSON.stringify(dataObject) |
|
|
|
var data = JSON.stringify(dataObject) |
|
|
@ -29,7 +29,7 @@ class EdgeEncryptor { |
|
|
|
|
|
|
|
|
|
|
|
const payload = JSON.parse(text) |
|
|
|
const payload = JSON.parse(text) |
|
|
|
const salt = payload.salt |
|
|
|
const salt = payload.salt |
|
|
|
return this.keyFromPassword(password, salt) |
|
|
|
return this._keyFromPassword(password, salt) |
|
|
|
.then(function (key) { |
|
|
|
.then(function (key) { |
|
|
|
const encryptedData = Unibabel.base64ToBuffer(payload.data) |
|
|
|
const encryptedData = Unibabel.base64ToBuffer(payload.data) |
|
|
|
const vector = Unibabel.base64ToBuffer(payload.iv) |
|
|
|
const vector = Unibabel.base64ToBuffer(payload.iv) |
|
|
@ -48,7 +48,7 @@ class EdgeEncryptor { |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
keyFromPassword (password, salt) { |
|
|
|
_keyFromPassword (password, salt) { |
|
|
|
|
|
|
|
|
|
|
|
var passBuffer = Unibabel.utf8ToBuffer(password) |
|
|
|
var passBuffer = Unibabel.utf8ToBuffer(password) |
|
|
|
var saltBuffer = Unibabel.base64ToBuffer(salt) |
|
|
|
var saltBuffer = Unibabel.base64ToBuffer(salt) |
|
|
|