Giter VIP home page Giter VIP logo

pkcs7's Introduction

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.

pkcs7's People

Contributors

dmlap avatar gkatsev avatar brandonocasey avatar

Stargazers

Eustațiu Iagăru avatar  avatar Kirito avatar  avatar Rocco Musolino avatar  avatar  avatar Peter Thanakrit Weekhamchai avatar Eakachai Varongsinghara avatar 始信 avatar  avatar  avatar NAKAMURA Masayuki avatar Marc Bachmann avatar Brandon Zacharie avatar  avatar Tian Permana avatar Todd Price avatar Marco Paland avatar tangyao avatar sofakeer avatar tom zhou avatar

Watchers

 avatar  avatar Jay Perry avatar Max avatar  avatar David McGaffin avatar Keith Mason avatar Blain Sadler avatar James Cloos avatar Erika Burbach avatar Chris Jeris avatar Vineet avatar  avatar David LaPalomento avatar Oscar Cortes avatar Joel Miller avatar  avatar Alex Farhadi avatar Stefan avatar  avatar  avatar  avatar Ben Ahern avatar James Zisk avatar Alex Bice avatar  avatar Robel Tezera avatar  avatar bcvio avatar  avatar  avatar Gustavo Castillo avatar  avatar  avatar

pkcs7's Issues

Please release new version

It appears several modifications to the library have been made since the latest release, 1.0.2. In particular this commit e075fe6 fixed the broken license declaration.

This library is in my package tree indirectly through video.js -> @videojs/http-streaming -> aes-decrypter -> pkcs7. And this package makes my license checker complain.

Unpad hex

How can unpad hex ...0020200030303 to ...0020200 ?

I am doing this:

let buffer = Buffer.from(paddedHex),
        bytes = new Uint8Array(buffer.length),
        i = buffer.length;

      while (i--) {
        bytes[i] = buffer[i];
      }

      Buffer.from(pkcs7.unpad(bytes)).toString('hex')

unpadding Node Buffer?

This does not appear to work on Node buffers out of the box, what kind of converting do i need to do?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.