A golang library to use aes encrypt easier.

Overview

Aes

a golang library to use aes encrypt easier.

Install

go get github.com/hanson/aes

Document

import

import github.com/hanson/aes

CBC

orig := "hello world"
key := "0123456789012345"

encryptCode := aes.AesEncryptCBC(orig, key)
fmt.Println("encrypt:" , encryptCode)
decryptCode := aes.AesDecryptCBC(encryptCode, key)
fmt.Println("decrypt:", decryptCode)

CFB

source := "hello world"
fmt.Println("origin:", source)
key := "ABCDEFGHIJKLMNO1" // 16 byte

encryptCode, err := aes.AesEncryptCFB([]byte(source), []byte(key))
if err != nil {
    log.Printf("err:%v", err)
    return
}

fmt.Println("encryptCode:", hex.EncodeToString(encryptCode))

decryptCode, err := aes.AesDecryptCFB(encryptCode, []byte(key))
if err != nil {
    log.Printf("err:%v", err)
    return
}

fmt.Println("decryptCode:", string(decryptCode))

CTR

source := "hello world"
fmt.Println("origin:", source)

key := "1443flfsaWfdasds"
encryptCode, err := aes.AesCryptCTR([]byte(source), []byte(key))
if err != nil {
    log.Printf("err:%v", err)
    return
}

fmt.Println("encryptCode:", string(encryptCode))

decryptCode, err := aes.AesCryptCTR(encryptCode, []byte(key))
if err != nil {
    log.Printf("err:%v", err)
    return
}

fmt.Println("decryptCode:", string(decryptCode))

ECB

source := "hello world"
fmt.Println("origin:", source)

//16 byte
key := "1443flfsaWfdas"
encryptCode := aes.AesEncryptECB([]byte(source), []byte(key))
fmt.Println("encryptCode:", string(encryptCode))

decryptCode := aes.AesDecryptECB(encryptCode, []byte(key))

fmt.Println("decryptCode:", string(decryptCode))

OFB

source := "hello world"
fmt.Println("origin:", source)
key := "1111111111111111" //16byte or 32byte

encryptCode, err := aes.AesEncryptOFB([]byte(source), []byte(key))
if err != nil {
    log.Printf("err:%v", err)
    return
}

fmt.Println("encryptCode:", hex.EncodeToString(encryptCode))

decryptCode, err := aes.AesDecryptOFB(encryptCode, []byte(key))
if err != nil {
    log.Printf("err:%v", err)
    return
}

fmt.Println("decryptCode:", string(decryptCode))
Owner
Keep learning in all of my life
null
Simple, fast and safe cross-platform linear binary stream communication protocol. AES key exchange based on ecc secp256k1

FFAX Protocol 2 dev 简体中文 Welcome to FFAX Protocol v2 Quick start go get github.com/RealFax/FFAX func example() { listener, err := net.Listen("tcp",

Realfax Messenger 15 Mar 21, 2022
This library aims to make it easier to interact with Ethereum through de Go programming language by adding a layer of abstraction through a new client on top of the go-ethereum library.

Simple ethereum client Simple ethereum client aims to make it easier for the developers to interact with Ethereum through a new layer of abstraction t

Jero 3 May 1, 2022
Dekripsi dari 2_Simple-Encrypt-Prima pakai golang

Dekripsi dari 2_Simple-Encrypt-Prima pakai golang

hilman kholik 0 Feb 15, 2022
🌰 encrypt/decrypt using ssh keys

ssh-vault ?? encrypt/decrypt using ssh private keys Documentation https://ssh-vault.com Usage $ ssh-vault -h Example: $ echo "secret" | ssh-vault -u

ssh-vault 345 May 16, 2022
`age-plugin-yubikey` implementation, encrypt things with a Yubikey/any PIV card

This is an age plugin for PIV cards/Yubikey. Your secret is kept safe on the tamperproof hardware, while letting you use the age command-line.

Tv 20 Dec 10, 2021
Secret - Encrypt anything with a password

Secret - Encrypt anything with a password Ever wanted to hide a file? Now you can do it really easily! Usage secret {-e/--encrypt | -d/--decrypt} <sou

Ishan Goel 31 Jan 31, 2022
Easily encrypt data for the Adyen payment platform

adyen Encrypt secrets for the Adyen payment platform. This library uses crypto/rand to generate cryptographically secure AES keys and nonces, and re-u

CrimsonAIO 33 May 3, 2022
Sign, verify, encrypt and decrypt data with GPG in your browser.

keygaen Sign, verify, encrypt and decrypt data with GPG in your browser. ⚠️ keygaen has not yet been audited! While we try to make keygaen as secure a

Felix Pojtinger 69 May 11, 2022
Xk6-crypto-x509 - A k6 extension to encrypt data with a PEM Public Key

xk6-crypto-x509 A k6 extension to encrypt data with a PEM Public Key This is a k

Rogério Kino 2 Jan 5, 2022
Card-encrypt - The encryption code necessary to enroll debit cards in the Palla API

?? Card RSA Encryption Thank you for choosing Palla! ?? In this repository you'l

palla 0 Feb 7, 2022
Easy to use encryption library for Go

encryptedbox EncryptedBox is an easy to use module for Go that can encrypt or sign any type of data. It is especially useful when you must serialize y

Jesse Swidler 18 Oct 26, 2021
Easy to use crypto library with multiple algorithms

crypka Crypka is library, which abstracts away crypto, so one can easily do: Swap cryptosystems by swapping algorithm object in one place Easily and s

null 1 Mar 6, 2022
An easy-to-use XChaCha20-encryption wrapper for io.ReadWriteCloser (even lossy UDP) using ECDH key exchange algorithm, ED25519 signatures and Blake3+Poly1305 checksums/message-authentication for Go (golang). Also a multiplexer.

Quick start Prepare keys (on both sides): [ -f ~/.ssh/id_ed25519 ] && [ -f ~/.ssh/id_ed25519.pub ] || ssh-keygen -t ed25519 scp ~/.ssh/id_ed25519.pub

null 24 Mar 21, 2022
Use golang to reproduce the basic blockchain

Blockchain_with_Go Use golang to reproduce the basic blockchain Update Panel V0.1 No transactions but noly blocks are allowed. V0.5 Transactions are n

null 10 Apr 8, 2022
Easy to use cryptographic framework for data protection: secure messaging with forward secrecy and secure data storage. Has unified APIs across 14 platforms.

Themis provides strong, usable cryptography for busy people General purpose cryptographic library for storage and messaging for iOS (Swift, Obj-C), An

Cossack Labs 1.5k May 6, 2022
Use the HashPassword function to generate a hashed value for the provided password

hasher Use the 'HashPassword' function to generate a hashed value for the provided password. h, err := hasher.HashPassword("password") // h == XohImNo

null 0 Nov 1, 2021
docker plugin use vault as secret provider.

docker plugin vault docker secret plugin for vault provider how to build docker plugin rm -fr plugin/rootfs/.dockerenv plugin/rootfs/* docker build -

Canux 0 Nov 5, 2021
A Console Application Use Pancakeswap To Swap Token

Pancakeswap Console A Pancakeswap Application Why It is a pity that some areas do not have access to the functions of PancakeSwap. I developed this to

Open Wallet 12 Dec 30, 2021
Shows how to use OpenCL with Go bindings.

Golang OpenCL example This is a tiny "hello world"-like application that shows how to use the github.com/jgillich/go-opencl OpenCL bindings for Go. Se

ErikL 3 Apr 1, 2022