pkcs7

1.0.4 • Public • Published

pkcs7

Build Status Greenkeeper badge Slack Status

NPM

Add and remove pkcs7-style padding.

Table of Contents generated with DocToc

Getting Started

Install the module with: npm install pkcs7

var pkcs7 = require('pkcs7'), encrypted;
// pad a buffer!
enctcrypted = encrypt(pkcs7.pad(buffer));
 
// later, you can unpad it:
console.log('the secret is out! ' + pkcs7.unpad(decrypt(encrypted)));

Install with cli command

$ npm install -g pkcs7
$ pkcs7 --help
$ pkcs7 --version

Documentation

PKCS#7 padding a really simple transformation some crytographic algorithms use to ensure the number of input bytes is a multiple of some constant. Here's how it works:

         01 -- if lth mod k = k-1
      02 02 -- if lth mod k = k-2
          .
          .
          .
k k ... k k -- if lth mod k = 0

k is the constant value the encryption algorithm wants your input to be a multiple of. This project assumes k is always sixteen. Not much to it, right? If reading specs is your thing, check out RFC 5652.

Examples

You can run pkcs7 from the command line:

# pad a string generated by echo and the hex dump the result 
echo -n "0123456789AB" | pkcs7 | xxd

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.

License

Copyright (c) 2014 Brightcove Licensed under the Apache-2 license.

Package Sidebar

Install

npm i pkcs7

Weekly Downloads

344,336

Version

1.0.4

License

Apache-2.0

Unpacked Size

23.3 kB

Total Files

20

Last publish

Collaborators

  • vmnavarro
  • dkingston
  • alfredo-reyes
  • jterranova
  • pradeep.vernekar
  • jfloresbc
  • mlopez.b
  • vasu.p
  • ttabrilla-bc
  • msivalls
  • sstevanus
  • rwbarber2
  • kaustubh-thube-brightcove
  • rwinger
  • bcc-bfranklin
  • apenigalapati
  • lmaultsby
  • sravan.pbr
  • agrojas-bc
  • ijunaidf
  • mgoncalves
  • mfregozo
  • arevelo
  • madhu_g
  • hugocjim
  • luisbacasehua
  • daniel_campos
  • kevin.schick
  • m.morrison
  • uomar
  • abarstowbc
  • sbarathan
  • kpandiyarajan
  • rburnham
  • imorones
  • walterseymourbc
  • ddashkevich
  • albertogomez
  • gestrada-br
  • amillerbrightcove
  • lvohra
  • mcho-bc
  • awaldron
  • fsalazarbc
  • dawnpacko
  • ldominguez
  • bc-srimron-soutter
  • rsilva_brightcove
  • joeylesh
  • lmelchorx1
  • juan-sanchez
  • eolvera
  • cloewer_bc
  • carredondo
  • brianhsu
  • niklagbrightcove
  • tsraveling_bc
  • bcbclifford
  • bc-acgarcia
  • adavila1
  • vaishalijayaraman
  • kreynolds
  • bgs-devops
  • albinjohnson
  • rtezera
  • bcmneil
  • randresf
  • v.kozlov_bc
  • nagendra_m
  • michaelmccarthybc
  • georgesanchez.diazjr
  • poneill-bcov
  • mdeltorobcov
  • jmohneycove
  • inbc01
  • aperezbrightcove
  • ireyes94
  • brightcove-admin
  • tedk
  • abradley-brightcove
  • bc-alive
  • lasanchezc
  • marguinbc
  • brightcove-user
  • kmason
  • cbarstow
  • hikeh
  • myerramalla
  • pdias
  • jwhisenant
  • ebertaud
  • oespinosac
  • dsalnikov
  • sharanya.muruganandam
  • vikaskumar.gajula
  • xgarcia_npm
  • jguerra
  • rjune
  • jonbwalsh
  • khaipham
  • wswanbeck
  • gastafurov
  • adalwani
  • ekelson-bcove
  • syseng
  • mcarreiro
  • elbadawimustafa
  • hwoodbury
  • jblaker
  • bcmauleon
  • paco_oblea_bc
  • jsepulveda
  • biswaranjan
  • barroyo
  • bmartinez
  • bc-jcarlson
  • eledezma
  • jcueto
  • erodrigues
  • psousa
  • acruzr
  • marcogaray
  • javibright
  • bcpsalas
  • etobin
  • ackbabe
  • cvillasenor
  • omartinez
  • mgonzalez_bc
  • pdohertybcov
  • muthukumar.bc
  • bzizmond
  • jmpmacedo
  • scorreia
  • lescorcio
  • cavieira
  • arunjeyaprasad
  • bvilvanathan
  • anand.gangadharan
  • rociosantos
  • agarciabcov
  • attinder
  • lauralopez
  • skumar85
  • hrodriguez2
  • jasilvaantonio
  • palvarezbc
  • ericramos
  • carlosabajo
  • ingrid.s.cruz
  • luis_fernando_lopez_ruiz
  • vishal64
  • tresa.baji
  • luis.garcia.brightcove
  • rodrigofdz
  • pgutierrezgil
  • harish17
  • jjeyaprakash
  • rrajendran1698
  • jlomeli
  • sjimenez
  • rwenger_brightcove
  • rujordan
  • stuartmh
  • jherrerabcov
  • mshiwal
  • ptamizh
  • akamalakkannan
  • roman-bc
  • tnwanna
  • bsahlas.npm
  • dherrera1109
  • hswaminathan
  • echengbc
  • sbarrettbc
  • dmlap