kjur / jsrsasign

The 'jsrsasign' (RSA-Sign JavaScript Library) is an opensource free cryptography library supporting RSA/RSAPSS/ECDSA/DSA signing/validation, ASN.1, PKCS#1/5/8 private/public key, X.509 certificate, CRL, OCSP, CMS SignedData, TimeStamp, CAdES and JSON Web Signature/Token in pure JavaScript.
https://kjur.github.io/jsrsasign
Other
3.25k stars 646 forks source link

messy code for Chinese #564

Closed wx05 closed 1 year ago

wx05 commented 1 year ago

hi , I'm try using it to get Google login credential , but when family_name or given_name is Chinese, it show messy code, Can you help me ? thanks

here is my code:

  var sJWS = googleUser.credential;

  var a = sJWS.split(".");
  var uHeader = b64utos(a[0]);
  var uClaim = b64utos(a[1]);

  var pHeader = KJUR.jws.JWS.readSafeJSONString(uHeader);
  var pClaim = KJUR.jws.JWS.readSafeJSONString(uClaim);

  var sHeader = JSON.stringify(pHeader, null, "  ");
  var sClaim = JSON.stringify(pClaim, null, "  ");
  console.log(uClaim)

here is messy code

{"iss":"https://accounts.google.com","nbf":1666775488,"aud":"xxxxx","sub":"xxxx","email":"xxxxx@gmail.com","email_verified":true,"azp":"xxxxx","name":"王轩","picture":"xxx","given_name":"轩","family_name":"王","iat":1666775788,"exp":1666779388,"jti":"xxxx"}
kjur commented 1 year ago

Please use b64utoutf8 instead of b64utos https://kjur.github.io/jsrsasign/api/symbols/global__.html

I hope this helps.

wx05 commented 1 year ago

Please use b64utoutf8 instead of b64utos https://kjur.github.io/jsrsasign/api/symbols/global__.html

I hope this helps.

Its work, thanks~