pkcs7

package module
v0.0.0-...-153b18e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 26, 2017 License: MIT Imports: 1 Imported by: 45

README

go-pkcs7

Simple package to pad and unpad data with PKCS7.

Details

It's common to use PKCS7 to pad and unpad data when using AES encryption. As far as I can tell, though Go has AES-128 encryption in its standard packages, it doesn't offer PKCS7 padding.

This package is designed to use while you're using the standard AES implementation.

Usage

import (
	"log"
	"github.com/richkzad/go-pkcs7"
)

original := []byte("hello")

var padded []byte
if padded, err := pkcs7.Pad(original, 16); err != nil {
	log.Fatalln(err)
}

var result []byte
if result, err := pkcs7.Unpad(padded, 16); err != nil {
	log.Fatalln(err)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Pad

func Pad(buf []byte, size int) ([]byte, error)

func Unpad

func Unpad(padded []byte, size int) ([]byte, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL