Code Monkey home page Code Monkey logo

go-jasypt's Introduction

jasypt

-- import "astuart.co/go-jasypt"

Package jasypt was created to assist in the decryption of jasypt-encrypted values. Many of the algorithms in this package are for legacy use only. Please use strong cryptographic algorithms and keys when encrypting your sensitive plaintext.

Note that many times base64 encoding has been applied to jasypt output, and thus you will likely need to base64 decode any strings before attempting to decrypt them.

Usage

const (
	AlgoPBEWithMD5AndDES = "PBEWithMD5AndDES"
)

Common implemented decryption algorithms

const (
	MaxLenMD5 = 20
)

Constants for maximum PBKDF1 key lengths

var (
	// ErrEmptyPassword denotes that a password is missing or empty. This is a
	// soft error.
	ErrEmptyPassword = fmt.Errorf("the password used was empty")
	// ErrExceededLength indicates that for a given hash function, the maximum
	// pbkdf1 length has been exceeded.
	ErrExceededLength = fmt.Errorf("derived key too long for md5")
)

func DecryptJasypt

func DecryptJasypt(encrypted []byte, password string) ([]byte, error)

DecryptJasypt takes bytes encrypted by the default Jasypt PBEWithMD5AndDES implementation, as well as a password, decrypts the byte slice, and returns a slice of the decrypted bytes. Any errors encountered will be returned.

func PBKDF1MD5

func PBKDF1MD5(pass, salt []byte, count, l int) ([]byte, error)

PBKDF1MD5 takes a password and salt, as well as an iteration count and key length in bytes, and a hash function, and returns the derived key and an error in the case that the key was too short.

type Decryptor

type Decryptor struct {
	Password, Algorithm string
}

A Decryptor encapsulates a password and Algorithm for more easily using common decryption across multiple ciphertexts.

func (Decryptor) Decrypt

func (d Decryptor) Decrypt(bs []byte) ([]byte, error)

Decrypt takes a slice of bytes and decrypts based on the password and algorithm specified, returning the slice of decrypted byts and any errors encountered.

go-jasypt's People

Contributors

andrewstuart avatar

Watchers

 avatar

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.