• Stars
    star
    213
  • Rank 185,410 (Top 4 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created almost 12 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

For encoding and decoding base64url!

base64url Build Status

Converting to, and from, base64url

Install

$ npm install base64url

After installing with npm you can require this library from JavaScript or TypeScript:

JavaScript

const base64url = require('base64url');

TypeScript:

import base64url from "base64url";

Usage

CLI

The CLI has been removed. For the time being, please install [email protected] if you need the CLI.

Library

base64url(input: string | Buffer, encoding: string = "utf8"): string

base64url.encode(input: string | Buffer, encoding: string = "utf8"): string

base64url encode input. Input should be a string or a Buffer.

Example

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

base64url.decode(input: string, encoding: string = "utf8"): string

Convert a base64url encoded string into a raw string. The encoding argument can be used if the input is a string that's not utf8.

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

base64url.fromBase64(input: string): string

Convert a base64 encoded string to a base64url encoded string.

Example

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

base64url.toBase64(input: string): string

Convert a base64url encoded string to a base64 encoded string.

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

base64url.toBuffer(input: string): Buffer

Convert a base64url encoded string to a Buffer containing the decoded bytes.

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

Alternatives

Supported Node.js versions

This library should be used with current versions of the Node.js runtime's long-term stable (LTS) schedule. More information can be found at the Node.js Release Working Group repo.

License

MIT

Copyright (c) 2013–2016 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.

More Repositories

1

buffer-crc32

A pure javascript CRC32 algorithm that plays nice with binary data
JavaScript
93
star
2

streamsql

A streaming, backend agnostic SQL ORM heavily inspired by levelup
JavaScript
67
star
3

python-jws

python implementation of JSON Web Signatures
Python
57
star
4

hookshot

Listen for webhooks, run some tasks
Rust
51
star
5

habitat

Small library for managing your environment variables
JavaScript
38
star
6

zlib-browserify

browserifyable zlib implementation for JavaScript
JavaScript
31
star
7

throttle-function

Takes a function, returns a function that will can only be called a certain amount of times per second.
JavaScript
28
star
8

airtable

Airtable API Client for Go
Go
25
star
9

gogo

An experimental ORM I didn't finish, for educational purposes only.
JavaScript
18
star
10

onion-ghost-blog

set up a ghost blog on tor in under 2 minutes
18
star
11

hyperproxy

Proxy with advanced routing capabilities
JavaScript
14
star
12

streampng

For messing with png chunks in a streaming fashion.
JavaScript
14
star
13

dataurl

Small node.js module for dealing with dataurls
JavaScript
14
star
14

messina

Pipe your Bunyan logs to Graylog2 with standard unix pipes
JavaScript
13
star
15

hacktionary

JavaScript
12
star
16

django-obi

Django open badge integration
Python
10
star
17

wigglyair

prototyping a music thing
Rust
9
star
18

altcaps

JavaScript
9
star
19

bleach.js

JavaScript
8
star
20

cleansocket

Cleans up old sockets before listening (solves EADDRINUSE)
JavaScript
8
star
21

auto-file-organizer

7
star
22

fileliststream

JavaScript
6
star
23

dotfiles

dotfiles, yo.
Emacs Lisp
6
star
24

posse-twitter

POSSE for Microblogging (twitter)
JavaScript
6
star
25

node-rtorrent

JavaScript
6
star
26

inaccessible-tweets-bookmarklet

make your twitter experience even worse by blurring tweets with inaccessible images (no alt text). spoiler: it's most of them.
JavaScript
5
star
27

tastyStorage

Delicious localStorage-like storage for your webapps.
JavaScript
5
star
28

sandwich

Given n-arrays of varaible length, find all of the combinations using one member from each.
JavaScript
5
star
29

grapheme-break-tests

A big pile of JSON that you can use to generate test cases for breaking on grapheme cluster boundaries.
JavaScript
5
star
30

learn-rust

Rust
5
star
31

cmdserver

client/server command line apps made easy
JavaScript
4
star
32

filesystem-browserify

JavaScript
4
star
33

opennews-prototype

whaaaaaaaat
JavaScript
4
star
34

airsupport

JavaScript
4
star
35

lernanta-cut

Cuttin' up lernanta PSD
JavaScript
4
star
36

restfulresource

A Drupal 6 module for providing resources in a way that can be read by ActiveResource 3.0
PHP
4
star
37

paulstretch

Mirrored from http://hypermammut.sourceforge.net/paulstretch/
C++
4
star
38

urlglob

Convert glob-like urls to regexps and match on them.
JavaScript
4
star
39

fuckingcongress

3
star
40

bjb.io-site

Personal website, yo
CSS
3
star
41

tweetpulse

This isn't worth looking at yet. The name will also change.
JavaScript
3
star
42

iterator-stream

Turn your iterators into streamable iterators
JavaScript
3
star
43

badge-demo

Badge Demo
JavaScript
3
star
44

badge-hub

Badge Hub
3
star
45

hyperproxy-cli

A simple CLI for hyperproxy
JavaScript
3
star
46

bitwriter

JavaScript
3
star
47

oort

cloud action
JavaScript
3
star
48

gov

JavaScript
3
star
49

oneshot

Tiny little server for making one request and shutting down. Useful for testing.
JavaScript
3
star
50

srccon-2016

CSS
2
star
51

brianlovesdata.github.com

Yo what up words.
2
star
52

planet.openbadges.org

Python
2
star
53

husort

JavaScript
2
star
54

emilygiorgione.org

CSS
2
star
55

express-router

Opinionated router enhancements for express
JavaScript
2
star
56

badge-builder

PHP
2
star
57

metapng.js

DEPRECATED, DON'T USE THIS.
JavaScript
2
star
58

words.brianloves.it

Bloooog
2
star
59

muntz

JavaScript
2
star
60

brianlovesthings.com

Source for brianlovesthings.com
JavaScript
2
star
61

recipes

2
star
62

batucada-design

Implementing redesign of Drumbeat.org
JavaScript
2
star
63

bitreader

JavaScript
2
star
64

algos

Implementations of different string distance algorithms in javascript.
JavaScript
2
star
65

p2pu-v2

P2PU website rewrite
Python
2
star
66

js-basic-challenge

Completing the JS Basic Badge challenge as an example.
2
star
67

badges-v3

Hackish demo for Badge Workshop
Ruby
2
star
68

nvm

You really want https://github.com/creationix/nvm
1
star
69

node-htmlsanitizer

JavaScript
1
star
70

badge-studio

JavaScript
1
star
71

hello-github-actions

Shell
1
star
72

bjb.dev

Astro
1
star
73

openbadges-federation

Federation for openbadges.
CSS
1
star
74

queens-js-2016

CSS
1
star
75

rust-experiments

Rust
1
star
76

chrome-bigquery-cost-estimator

JavaScript
1
star
77

notion-faceoff

turn off those faces that move around so you can focus on the text
JavaScript
1
star