Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

base64-file-encoder

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

base64-file-encoder

base64 encode/decode a file and save it to disk

  • 1.4.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
14
increased by366.67%
Maintainers
1
Weekly downloads
 
Created
Source

npm Hits

base64-file-encoder

A Node.js module to base64 encode/decode a file and save it to disk

NPM

Installation

Install with npm:

$ npm install base64-file-encoder --save

Example

const b64File = require('base64-file-encoder');


// base64 encodes the content of foo.txt and outputs it to bar.txt
b64File.encode('foo.txt', 'bar.txt')
  .then(function(){
    // if foo.txt content was 'foo', bar.txt content will be 'Zm9v'
    console.log('file was encoded');
  })
  .catch(function(error){
    console.log(error);
  });


// base64 encodes the content of foo.txt and outputs it to the same
// file (i.e. overwrites it)
b64File.encode('foo.txt')
  .then(function(){
    console.log('file was encoded and overwritten');
  })
  .catch(function(error){
    console.log(error);
  });


// base64 decodes the content of bar.txt and outputs it to foo.txt
b64File.decode('bar.txt', 'foo.txt')
  .then(function(){
    // if bar.txt content was 'Zm9v', foo.txt content will be 'foo'
    console.log('file was decoded');
  })
  .catch(function(error){
    console.log(error);
  });


// base64 decodes the content of bar.txt and outputs it to the same
// file (i.e. overwrites it)
b64File.decode('bar.txt')
  .then(function(){
    console.log('file was decoded and overwritten');
  })
  .catch(function(error){
    console.log(error);
  });

API

encode(inputFilePath, [outputFilePath])

Base64 encodes the contents of a file and outputs it to another file (outputFilePath) or to the same file (if outputPath is not provided).
This function returns a promise.

decode(inputFilePath, [outputFilePath])

Decodes the contents of a base64 encoded file and outputs it to another file (outputFilePath) or to the same file (if outputPath is not provided).
This function returns a promise.

License

MIT. See LICENSE.md for details.

Keywords

FAQs

Package last updated on 04 Sep 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc