You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

base64url

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

base64url

For encoding to/from base64urls


Version published
Weekly downloads
2.2M
increased by3.88%
Maintainers
1
Created
Weekly downloads
 

Package description

What is base64url?

The base64url npm package provides utilities for encoding and decoding data in base64url format, which is a URL-safe variant of base64. It is commonly used to encode data in a way that can be safely transmitted over URLs without encoding issues.

What are base64url's main functionalities?

Encoding to base64url

This feature allows you to encode a string or buffer into base64url format. The provided code sample demonstrates how to encode the string 'Hello World!' using the base64url package.

"use strict"; const base64url = require('base64url'); const encoded = base64url('Hello World!'); console.log(encoded);

Decoding from base64url

This feature enables you to decode a base64url encoded string back into its original form. The code sample shows how to decode the string 'SGVsbG8gV29ybGQh' back to 'Hello World!'.

"use strict"; const base64url = require('base64url'); const decoded = base64url.decode('SGVsbG8gV29ybGQh'); console.log(decoded);

From base64 to base64url

This feature allows you to convert a base64 encoded string to a base64url encoded string. The code sample illustrates converting a base64 string 'SGVsbG8gV29ybGQh==' to base64url format.

"use strict"; const base64url = require('base64url'); const base64 = 'SGVsbG8gV29ybGQh=='; const base64urlString = base64url.fromBase64(base64); console.log(base64urlString);

To base64 from base64url

This feature converts a base64url encoded string back to a standard base64 encoded string. The code sample demonstrates converting 'SGVsbG8gV29ybGQh' from base64url to regular base64.

"use strict"; const base64url = require('base64url'); const base64urlString = 'SGVsbG8gV29ybGQh'; const base64 = base64url.toBase64(base64urlString); console.log(base64);

Other packages similar to base64url

Readme

Source

base64url Build Status

Converting to, and from, base64url

Install

$ npm install base64url

Usage

CLI

$ npm install -g base64url

$ echo 'Here is some text to encode' | base64url
> SGVyZSBpcyBzb21lIHRleHQgdG8gZW5jb2RlCg

$ echo SGVyZSBpcyBzb21lIHRleHQgdG8gZW5jb2RlCg | base64url -D
> Here is some text to encode

$ base64url --help

  For encoding to/from base64urls

  Usage: base64url [-hvD] [-b num] [-i in_file] [-o out_file]
    -h, --help     display this message
    -v, --version  display version info
    -D, --decode   decodes input
    -b, --break    break encoded string into num character lines
    -i, --input    input file (default: stdin)
    -o, --output   output file (default: stdout),

Library

base64url(stringOrBuffer)

base64url.encode(stringOrBuffer)

base64url encode stringOrBuffer

Example

> base64url('ladies and gentlemen, we are floating in space')
'bGFkaWVzIGFuZCBnZW50bGVtYW4sIHdlIGFyZSBmbG9hdGluZyBpbiBzcGFjZQ'

base64url.decode(b64UrlEncodedString, [encoding])

Convert a base64url encoded string into a raw string. Encoding defaults to 'utf8'.

> base64url.decode('cmlkZTogZHJlYW1zIGJ1cm4gZG93bg')
'ride: dreams burn down'

base64url.fromBase64(b64EncodedString)

Convert a base64 encoded string to a base64url encoded string

Example

> base64url.fromBase64('qL8R4QIcQ/ZsRqOAbeRfcZhilN/MksRtDaErMA==')
'qL8R4QIcQ_ZsRqOAbeRfcZhilN_MksRtDaErMA'

base64url.toBase64(b64UrlEncodedString)

Convert a base64url encoded string to a base64 encoded string

> base64url.toBase64('qL8R4QIcQ_ZsRqOAbeRfcZhilN_MksRtDaErMA')
'qL8R4QIcQ/ZsRqOAbeRfcZhilN/MksRtDaErMA=='

base64url.toBuffer(b64UrlEncodedString)

Convert a base64url encoded string to a Buffer

> base64url.toBuffer('c3Bpcml0dWFsaXplZA')
<Buffer 73 70 69 72 69 74 75 61 6c 69 7a 65 64>

License

MIT

Copyright (c) 2014 Brian J. Brennan

Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Keywords

FAQs

Package last updated on 07 Dec 2014

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc