JSEncrypt encrypt return false to troubleshoot and solve

2018-04-11 wrote
Today, the JSEncrypt encryption algorithm in the test environment failed to return false, resulting in an encryption algorithm error and the interface cannot be called correctly.

 

Encryption code snippet:

 

var ras = new JSEncrypt ();
ras.setPublicKey ('MIIBxxxxB');
console.log(ras, ras.encrypt(222));

 

 This code is fine in the production environment and returns the encryption result correctly: ras structure:

 

The encryption result returned by the test environment is: false

 

Chrome Debug debugging results:

 

After debugging and rolling back the code, it was found that there was a conflict with the base64 code, resulting in incorrect decryption.

Regarding the conflict part, we will continue to track and find the source in our spare time.

 

solution:

Remove import {Base64} and replace it with require('js-base64').Base64

wrote
// Remove import method, separate the code socpe
import { Base64 } from 'js-base64'; // Remove


// Use require method
export function basicAuth({username}) {
  const Base64 = require('js-base64').Base64;
  return `Basic ${Base64.encode(`${username}`)}`;
}

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326176726&siteId=291194637