Giter Site home page Giter Site logo

acuao / base64-advanced-cli Goto Github PK

View Code? Open in Web Editor NEW
4.0 2.0 0.0 222 KB

Base64 encode/decode command line interface (CLI) with advanced features

Home Page: https://www.npmjs.com/package/base64-advanced-cli

License: MIT License

JavaScript 37.00% TypeScript 58.35% HTML 4.65%
64 base base64 cli decode decoding encode encoding file command command-line command-line-tool jwt

base64-advanced-cli's Introduction

Release BuildTest

base64-advanced-cli

This command line interface helps you to encode/decode base64 data with advanced features like files encoding/decoding, jwt review and html image encoding.

Install

$ npm install --global base64-advanced-cli

... or just try it without installing it :

$ npx base64-advanced-cli -e "Hello World!"

... or try the Online Demo ๐Ÿ’ช

Usage

This CLI provides the following command : b64

88             ad8888ba,          ,d8    
88            8P'    "Y8        ,d888    
88           d8               ,d8" 88    
88,dPPYba,   88,dd888bb,    ,d8"   88    
88P'    "8a  88P'    `8b  ,d8"     88    
88       d8  88       d8  8888888888888  
88b,   ,a8"  88a     a8P           88    
8Y"Ybbd8"'    "Y88888P"            88    
                                         
                                         
base64-advanced-client v1.x.x
Usage: b64 [options]

Options:
  -d, --decode [data]           set mode to encoding
  -e, --encode [data]           set mode to decoding
  -i, --input-file <filename>   read input from a file
  -o, --output-file <filename>  write output to a file
  -v, --version                 display the version of this CLI
  --jwt <data>                  display the content of a jwt token
  --html                        encode an image into an html tag containing base64 data
  --no-update-notification      do not display update notifications
  -h, --help                    display help for command

Usage examples :

Encoding :

$ b64 -e "Hello World!"

Will return SGVsbG8gV29ybGQh value.

Decoding :

$ b64 -d SGVsbG8gV29ybGQh

Will return Hello World! value.

Writing output to a file :

$ b64 -d SGVsbG8gV29ybGQh -o decoded.txt

Will create a file named decoded.txt containingext " Hello world! " text, instead of displaying the output in the console.

Reading input from a file :

$ b64 -e -i decoded.txt

Will read file contents and encodode it, rather than using the command input.

Stdin usage

You can also read input from stdin (only on unix systems) to encode & decode data

$ echo "Hello World!" | b64 -e

will return SGVsbG8gV29ybGQhCg==.

stdin is also applicable for decoding purposes

$ echo SGVsbG8gV29ybGQhCg== | b64 -d

will return Hello World!.

JWT Preview :

This CLI provides a simple way to preview the content of JWT tokens.

$ b64 --jwt eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiSm9obiBEb2UiLCJpYXQiOjE1MTYyMzkwMjJ9.hqWGSaFpvbrXkOWc6lrnffhNWR19W_S1YKFBx2arWBk

will return the following output :

Header : {
    "alg": "HS256",
    "typ": "JWT"
}
Body : {
    "name": "John Doe",
    "iat": 1516239022
}

โš ๏ธ The CLI does NOT validate the signature of the token since this is not the purose of this tool.

HTML Image base 64 encoding :

You can use this CLI to directly encode your images as html base64 images (with automatic mime type dectection).

$  b64 -e --html -i image.png

Will return the html tag containing the encoded image in base 64 format (e.g. <img src="data:image/png;base64,iVBORw0K[...]g==" />).

$ b64 -e --html -i image.png -o image.html

Will perform the same operation but will save the image html content in a file rather than simply displaying the output.

Releases

Find all releases on npm : https://www.npmjs.com/package/base64-advanced-cli

โš ๏ธ Note

This library is still under development some changes may occur, great features incoming ๐Ÿ’ช.

Any improvement ideas are welcome, feel free to create issues for evolutions/bugs on the repository of the project.

base64-advanced-cli's People

Contributors

acuao avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

base64-advanced-cli's Issues

Error: ENOENT: no such file or directory, open './build/b64.txt'

Hello, @Acuao!

I've already used your utility few month ago and that time it could create output path folders if they didn't exist. In my case I have no "build" folder in my project until I need it and I want b64 to create this folder when it encodes an image. It worked but today i copy-pasted the command I used last time in the same project, and now I get an error Error: ENOENT: no such file or directory, open './build/b64.txt'.

I've already met this error last time but this was caused by a mistyped space in the beginning of the terminal line. When I fixed it, b64 started to create folder that didn't exist.

Today I tried to run b64 when the destination folder existed, and it worked fine but it fails if the folder didn't exist.

Could you explain, please, if b64 should create folders recursively, that don't exist, or not? I'm almost sure it worked :) Maybe you could guide me towards the proper fix of the error.

Anyway thank you for b64, it's very convenient and fast, and increase my work pace โค

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.