Skip to content

Commit 62e791f

Browse files
committed
fixes issue with decryption
1 parent be0f157 commit 62e791f

2 files changed

Lines changed: 11 additions & 5 deletions

File tree

app/services/yahooService.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,14 +132,20 @@ function getHistoricalPrices(ticker, options) {
132132

133133
// Helper functions
134134
function getDecryptedBody(dataStore) {
135-
let _cs = dataStore._cs
136-
let _cr = dataStore._cr
135+
let pwKey = Object.keys(dataStore)[2];
136+
var password = dataStore[pwKey];
137+
137138
stores = dataStore.context.dispatcher.stores
138-
var key = CryptoJS.algo.PBKDF2.create({ keySize: 8 }).compute(_cs, JSON.parse(_cr)).toString();
139-
var plaintext = CryptoJS.AES.decrypt(stores, key);
139+
var plaintext = CryptoJS.AES.decrypt(stores, password);
140140
return JSON.parse(decodeURIComponent(escape(CryptoJS.enc.Latin1.stringify(plaintext))));
141141
}
142142

143+
function getJsonLastElement(json)
144+
{
145+
let len = json.length
146+
return json[len - 1]
147+
}
148+
143149
function getDataStoreAsJson(body) {
144150
return JSON.parse("{"+body.split(regex)[1]+"}")
145151
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "terminal-stocks",
3-
"version": "1.0.11",
3+
"version": "1.0.12",
44
"description": "Fetch stock price information on terminal",
55
"main": "index.js",
66
"bin": {

0 commit comments

Comments
 (0)