GithubHelp home page GithubHelp logo

goaes's Introduction

goAES

Simple package for AES encryption and decryption. It use sha256 for hash the secret key. Based on CTR

BuildStatus ReportCard Go Coverage Codacy Badge codebeat badge Maintainability GolangCI Open Source Helpers

GoDoc FOSSA Status MIT license

Usage

Encryption

package main

import (
	"fmt"
	"log"

	goaes "github.com/syronz/goAES"
)

func main() {
	aes, err := goaes.New().Key("secret key").IV("iv is 16 char!!!").Build()
	if err != nil {
		log.Fatal(err)
	}

	term := "Hello"
	encrypted := aes.Encrypt(term)

	fmt.Printf("Encryption of %q is %q \n", term, encrypted)
}

output:

Encryption of "Hello" is "257d85d55b" 

Decryption

Default length is 100 character, in case the orginal term is more than 100 in AES decryption, you shold mention the Length in the build.

package main

import (
	"fmt"
	"log"

	goaes "github.com/syronz/goAES"
)

func main() {
	aes, err := goaes.New().Key("secret key").IV("iv is 16 char!!!").Build()
	if err != nil {
		log.Fatal(err)
	}

	encrypted := "257d85d55b"
	decrypted := aes.Decrypt(encrypted)

	fmt.Printf("Decryption of %q is %q \n", encrypted, decrypted)
}

output:

Decryption of "257d85d55b" is "Hello" 

Note

In case of the length of decrypted word is more than 100, we should use .Length(int) like here. Extra chars will be trimmed

aes, err := goaes.New().Key("secret key").IV("iv is 16 char!!!").Length(10000).Build()

Online test

By going to the gchq.github.io/CyberChef you can test it manually

License

FOSSA Status

goaes's People

Contributors

fossabot avatar syronz avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

fossabot

goaes'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.