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

base32-encode

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

base32-encode - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

LICENSE

12

index.js

@@ -5,4 +5,5 @@ var RFC4648 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567'

module.exports = function base32Encode (buffer, variant) {
var alphabet, padding
module.exports = function base32Encode (buffer, variant, options) {
options = options || {}
var alphabet, defaultPadding

@@ -13,11 +14,11 @@ switch (variant) {

alphabet = RFC4648
padding = true
defaultPadding = true
break
case 'RFC4648-HEX':
alphabet = RFC4648_HEX
padding = true
defaultPadding = true
break
case 'Crockford':
alphabet = CROCKFORD
padding = false
defaultPadding = false
break

@@ -28,2 +29,3 @@ default:

var padding = (options.padding !== undefined ? options.padding : defaultPadding)
var length = buffer.byteLength

@@ -30,0 +32,0 @@ var view = new Uint8Array(buffer)

{
"name": "base32-encode",
"version": "1.0.0",
"version": "1.1.0",
"license": "MIT",

@@ -5,0 +5,0 @@ "repository": "LinusU/base32-encode",

@@ -23,2 +23,5 @@ # Base32 Encode

console.log(base32Encode(buffer, 'RFC4648', { padding: false }))
//=> ORSXG5A
console.log(base32Encode(buffer, 'RFC4648-HEX'))

@@ -30,6 +33,8 @@ //=> EHIN6T0=

### base32Encode(buffer, variant)
### base32Encode(buffer, variant, options)
- `buffer` <ArrayBuffer>
- `variant` <String>
- `options` <Object>
- `padding` <Boolean>

@@ -44,4 +49,6 @@ Encode the data in `buffer`. `variant` should be one of the supported variants

Options may have a `padding` property which provides a way to forcefully enable or disable padding. The default behavior is to follow the default of the selected variant.
## See also
- [base32-decode](https://github.com/LinusU/base32-decode) - Base32 decoder

@@ -68,4 +68,10 @@ var assert = require('assert')

// base32 encode with no options
testCases.forEach(function (testCase) {
assert.equal(base32Encode(hexToArrayBuffer(testCase[1]), testCase[0]), testCase[2])
})
// base32 encode with disabled padding option
testCases.forEach(function (testCase) {
assert.equal(base32Encode(hexToArrayBuffer(testCase[1]), testCase[0], { padding: false }), testCase[2].replace(/=/g, ''))
})
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