1.0.0 • Published 10 months ago

xml64 v1.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
10 months ago

xml64

xml64 is a utility package for converting between Base64 encoded strings and XML. This package provides functions to easily encode XML strings into Base64 and decode Base64 strings back into XML.

Installation

You can install xml64 using npm or yarn:

npm install xml64
# or
yarn add xml64

Features

  • Convert Base64 encoded strings to XML strings.
  • Convert XML strings to Base64 encoded strings.
  • Works in both CommonJS and ES Module environments.

Usage

CommonJS Example

For Node.js or CommonJS environments:

const { base64ToXml, xmlToBase64 } = require('xml64');

// Convert Base64 to XML
const base64 = "PHhscD5zdHJpbmc8L3hscD4=";
const xmlString = base64ToXml(base64);
console.log(xmlString); // Outputs: "<xml>string</xml>"

// Convert XML to Base64
const xml = "<xml>string</xml>";
const base64Encoded = xmlToBase64(xml);
console.log(base64Encoded); // Outputs: "PHhscD5zdHJpbmc8L3hscD4="

ES Modules Example

For ES Modules environments or modern JavaScript (e.g., in TypeScript):

import { base64ToXml, xmlToBase64 } from 'xml64';

// Convert Base64 to XML
const base64 = "PHhscD5zdHJpbmc8L3hscD4=";
const xmlString = base64ToXml(base64);
console.log(xmlString); // Outputs: "<xml>string</xml>"

// Convert XML to Base64
const xml = "<xml>string</xml>";
const base64Encoded = xmlToBase64(xml);
console.log(base64Encoded); // Outputs: "PHhscD5zdHJpbmc8L3hscD4="

Author

License

MIT © 2024 Behzad Bakhshayesh

1.0.0

10 months ago

0.1.0

10 months ago