Giter VIP home page Giter VIP logo

crypt's Introduction

crypt

A simple Go library for cryptographic

Simple example

import "github.com/kayon/crypt"

func main() {

    ...

    c, err := crypt.NewAES(key, nil, crypt.Options{Padding: crypt.PAD_ZEROPADDING})
    if err != nil {
        ...
    }

    // encrypt
    ciphertext, err := c.Encrypt(plaintext)

    // decrypt
    plaintext, err = c.Decrypt(ciphertext)

    ...

    // shortcuts
    ciphertext, err := crypt.AES.Encrypt(plaintext, key, nil, crypt.Options{Mode: crypt.MODE_CBC, Padding: crypt.PAD_ANSIX923})

}

List of methods

AES

NewAES(key, iv []byte, args ...Options) (*Crypt, error)

DES

NewDES(key, iv []byte, args ...Options) (*Crypt, error)

Triple DES

NewDES3(key, iv []byte, args ...Options) (*Crypt, error)

ChaCha20

NewChaCha20(key, iv []byte)(*Crypt, error)

Blowfish

NewBlowfish(key[]byte) (*Crypt, error)

RC4

NewRC4(key []byte) (*Crypt, error)

Crypt

(Crypt) Encrypt(plaintext []byte) (ciphertext []byte, err error)

(Crypt) Decrypt(ciphertext []byte) (plaintext []byte, err error)

Shortcuts

AES

  • AES.Encrypt(plaintext, key, iv []byte, args ...Options) ([]byte, error)

  • AES.Decrypt(ciphertext, key, iv []byte, args ...Options) ([]byte, error)

DES

  • DES.Encrypt(plaintext, key, iv []byte, args ...Options) ([]byte, error)

  • DES.Decrypt(ciphertext, key, iv []byte, args ...Options) ([]byte, error)

DES3

  • DES3.Encrypt(plaintext, key, iv []byte, args ...Options) ([]byte, error)

  • DES3.Decrypt(ciphertext, key, iv []byte, args ...Options) ([]byte, error)

ChaCha20

  • ChaCha20.Encrypt(plaintext, key, iv []byte) ([]byte, error)

  • ChaCha20.Decrypt(ciphertext, key, iv []byte) ([]byte, error)

Blowfish

  • Blowfish.Encrypt(plaintext, key []byte) ([]byte, error)

  • Blowfish.Decrypt(ciphertext, key []byte) ([]byte, error)

RC4

  • RC4.Encrypt(plaintext, key []byte) ([]byte, error)

  • RC4.Decrypt(ciphertext, key []byte) ([]byte, error)

MD5

  • MD5.Sum(plaintext []byte) []byte

  • MD5.Hex(plaintext []byte) string

Sha3

  • Sha3.Sum224(data []byte) []byte

  • Sha3.Sum256(data []byte) []byte

  • Sha3.Sum384(data []byte) []byte

  • Sha3.Sum512(data []byte) []byte

  • Sha3.Shake128(data []byte, size int) (hash []byte)

  • Sha3.Shake256(data []byte, size int) (hash []byte)

Options.Mode

block cipher mode

  • MODE_CBC default

    CBC Cipher-block chaining

  • MODE_CFB

    CFB Cipher feedback

  • MODE_CTR

    CTR Counter mode

  • MODE_OFB

    OFB Output feedback

  • MODE_GCM

    GCM Galois/Counter Mod

  • MODE_ECB

    ECB Electronic codebook

Options.Padding

  • PAD_PKCS7 default

    PKCS#7 RFC 5652

  • PAD_ISO97971

    ISO/IEC 9797-1 Padding Method 2

  • PAD_ANSIX923

    ANSI X.923

  • PAD_ISO10126

    ISO 10126

  • PAD_ZEROPADDING

    Zero padding

  • PAD_NOPADDING

crypt's People

Contributors

kayon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

crypt's Issues

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.