npm's personal messenger

    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.

    Install

    npm i pkcs7

    DownloadsWeekly Downloads

    362,159

    Version

    1.0.4

    License

    Apache-2.0

    Unpacked Size

    23.3 kB

    Total Files

    20

    Last publish

    Collaborators

    • uomar
    • abarstowbc
    • sbarathan
    • adamico-bc
    • kpandiyarajan
    • msivalls
    • vbustillos
    • rburnham
    • imorones
    • bhong-brightcove
    • walterseymourbc
    • ddashkevich
    • shubham.chavhan
    • albertogomez
    • gestrada-br
    • lpintor
    • amillerbrightcove
    • lvohra
    • daniel.gutierrez.brightcove
    • charles.seat
    • erick-valdivia
    • victor-rivas
    • mcho-bc
    • awaldron
    • fsalazarbc
    • dawnpacko
    • j.hawleypeters.bc
    • adamboudionbc
    • jimmy-carfagno-bc
    • ldominguez
    • bc-srimron-soutter
    • prasant7bc
    • bart-stevens-bc
    • rsilva_brightcove
    • joeylesh
    • lmelchorx1
    • juan-sanchez
    • eolvera
    • cloewer_bc
    • carredondo
    • brianhsu
    • lewis.moten.brightcove
    • niklagbrightcove
    • tsraveling_bc
    • natedennis
    • bcbclifford
    • craigparrottebc
    • mwebster789
    • bc-acgarcia
    • adavila1
    • vaishalijayaraman
    • kreynolds
    • bgs-devops
    • albinjohnson
    • lmaultsby
    • rtezera
    • bcmneil
    • randresf
    • v.kozlov_bc
    • nagendra_m
    • michaelmccarthybc
    • georgesanchez.diazjr
    • poneill-bcov
    • mdeltorobcov
    • scottbishop
    • bcov_david-kelly
    • yji_bc
    • jmohneycove
    • inbc01
    • jeff.schuman
    • a_castillo_h
    • aperezbrightcove
    • ireyes94
    • brightcove-admin
    • tedk
    • abradley-brightcove
    • bc-alive
    • mrocajr
    • 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
    • asinclair
    • hwoodbury
    • jblaker
    • bcmauleon
    • paco_oblea_bc
    • jsepulveda
    • biswaranjan
    • barroyo
    • bmartinez
    • bc-jcarlson
    • eledezma
    • jcueto
    • erodrigues
    • psousa
    • acruzr
    • marcogaray
    • diegocruz1991
    • javibright
    • bcpsalas
    • etobin
    • ackbabe
    • cvillasenor
    • omartinez
    • mgonzalez_bc
    • pdohertybcov
    • muthukumar.bc
    • bzizmond
    • jmpmacedo
    • scorreia
    • lescorcio
    • cavieira
    • mbalasubramaniam
    • arunjeyaprasad
    • bvilvanathan
    • anand.gangadharan
    • rociosantos
    • fdelgado_bc
    • syurishi
    • agarciabcov
    • attinder
    • lauralopez
    • granganathan
    • 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
    • jhurtado
    • sjimenez
    • rwenger_brightcove
    • rujordan
    • stuartmh
    • jherrerabcov
    • mshiwal
    • ptamizh
    • akamalakkannan
    • akatare
    • roman-bc
    • tnwanna
    • bsahlas.npm
    • dherrera1109
    • hswaminathan
    • lramirez-bc
    • echengbc
    • sbarrettbc
    • dmlap