Open wperrigo opened 6 years ago
Never seen such problem. Can you show me the code that you use to encode the token?
// SET ENCRYPTION OPTIONS FOR THE JSON TOKENS
const clientOptions = {
crypt: {
cypher: 'AES-256-CBC',
key: 'hidden_super_secret_key'
},
connectionDefaultSettings: {
rdp: {
'create-drive-path': true,
'security': 'any',
'ignore-cert': true,
'enable-wallpaper': false,
'create-recording-path': true
}
}
}
const encrypt = (value) => {
const iv = crypto.randomBytes(16)
const cipher = crypto.createCipheriv(clientOptions.crypt.cypher, clientOptions.crypt.key, iv)
let crypted = cipher.update(JSON.stringify(value), 'utf8', 'base64')
crypted += cipher.final('base64')
const data = {
iv: iv.toString('base64'),
value: crypted
}
return new Buffer(JSON.stringify(data)).toString('base64')
}
I was always getting a failure in the Decrypt method due to character issues. I had to replace one line to get it to work.
This:
let encoded = JSON.parse(this.constructor.base64decode(encodedString));
Became this:
let tempJSON = this.constructor.base64decode(encodedString) let encoded = JSON.parse(tempJSON.substr(0, tempJSON.indexOf('}')+1));
Thank you very much. This replacement fixes my problem XD
I was always getting a failure in the Decrypt method due to character issues. I had to replace one line to get it to work.
This:
let encoded = JSON.parse(this.constructor.base64decode(encodedString));
Became this:
let tempJSON = this.constructor.base64decode(encodedString) let encoded = JSON.parse(tempJSON.substr(0, tempJSON.indexOf('}')+1));