Skip to content
/ goAES Public

Simple package for AES encryption and decryption written in golang

License

Notifications You must be signed in to change notification settings

syronz/goAES

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Simple package for AES encryption and decryption written in golang

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages