Skip to content

Commit

Permalink
fixes issue with decryption
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-hmmr committed Jan 14, 2023
1 parent be0f157 commit 62e791f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
14 changes: 10 additions & 4 deletions app/services/yahooService.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,20 @@ function getHistoricalPrices(ticker, options) {

// Helper functions
function getDecryptedBody(dataStore) {
let _cs = dataStore._cs
let _cr = dataStore._cr
let pwKey = Object.keys(dataStore)[2];
var password = dataStore[pwKey];

stores = dataStore.context.dispatcher.stores
var key = CryptoJS.algo.PBKDF2.create({ keySize: 8 }).compute(_cs, JSON.parse(_cr)).toString();
var plaintext = CryptoJS.AES.decrypt(stores, key);
var plaintext = CryptoJS.AES.decrypt(stores, password);
return JSON.parse(decodeURIComponent(escape(CryptoJS.enc.Latin1.stringify(plaintext))));
}

function getJsonLastElement(json)
{
let len = json.length
return json[len - 1]
}

function getDataStoreAsJson(body) {
return JSON.parse("{"+body.split(regex)[1]+"}")
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "terminal-stocks",
"version": "1.0.11",
"version": "1.0.12",
"description": "Fetch stock price information on terminal",
"main": "index.js",
"bin": {
Expand Down

0 comments on commit 62e791f

Please sign in to comment.