Miscellaneous Encoding Utilities for Crypto-related Objects in JavaScript
npm install js-encoding-utilsMiscellaneous Encoding Utilities for Crypto-related Objects in JavaScript
--

!Unit Test



> WARNING: At this time this solution should be considered suitable for research and experimentation, further code and security review is needed before utilization in a production application.
- From npm/yarn:
``shell`
$ npm install --save js-encoding-utils // npm
$ yarn add js-encoding-utils // yarn
- From GitHub:
`shell`
$ git clone https://github.com/junkurihara/jseu.git
Then you should import the package as follows.
`javascript`
import jseu from 'js-encoding-utils'; // for npm
import jseu from 'jseu/dist/index.js'; // for github
javascript
// msg is an ArrayBuffer or Typed Array
const encoded = jseu.encoder.encodeBase64(msg);
// now you get Base64 stringconst decoded = jseu.encoder.decodeBase64(encoded);
// now you get the original message in Uint8Array
`Base64Url <-> Binary
`javascript
// msg is an ArrayBuffer or Typed Array
const encoded = jseu.encoder.encodeBase64Url(msg);
// now you get Base64Url stringconst decoded = jseu.encoder.decodeBase64Url(encoded);
// now you get the original message in Uint8Array
`HexString <-> Binary
`javascript
// msg is an ArrayBuffer or Typed Array
const encoded = jseu.encoder.arrayBufferToHexString(msg);
// now you get the hex-stringified message stringconst decoded = jseu.encoder.hexStringToArrayBuffer(encoded);
// now you get the original message in Uint8Array
`PEM <-> Binary (usually DER encoding)
`javascript
// X.509 formatted certificate
const certPEM ='-----BEGIN CERTIFICATE-----...';const binCert = jseu.formatter.pemToBin(certPEM);
// now you get the DER encoded certificate in Uint8Array
const pemCert = jseu.formatter.binToPem(binCert, 'certificate');
// now you get the original certificate.
`License
Licensed under the MIT license, see LICENSE` file.