Skip to content

Latest commit

 

History

History
47 lines (40 loc) · 1.06 KB

README.md

File metadata and controls

47 lines (40 loc) · 1.06 KB

Instalation

go get github.com/gilang-as/endecrypt

Example

package main

import (
	"fmt"
	"github.com/gilang-as/endecrypt"
)

func main() {
	endecryptExample()
	aesExample()
}

func endecryptExample()  {
	fmt.Println("==========[ Endecrypt Example ]==========")
	SecretKey := "ExampleSecretKey123!!!"
	SecretIV := "ExampleSecretIV000!!!!."
	a := endecrypt.EndecryptConfig(SecretKey, SecretIV)

	plainText := "Hello World"
	fmt.Println("Before Encrypt : ", plainText)

	cipherText := a.Encrypt(plainText)
	fmt.Println("After Encrypt : ", cipherText)

	decrypt := a.Decrypt(cipherText)
	fmt.Println("After Decrypt : ", decrypt)
}

func aesExample()  {
	fmt.Println("==========[ AES Example ]==========")
	passphrase := endecrypt.GenerateAesKey()
	fmt.Println("Passphrase : ", passphrase)
	c := endecrypt.AesConfig(passphrase)
	plainText := "Hello World"
	fmt.Println("Before Encrypt : ", plainText)
	cipherText := c.Encrypt(plainText)
	fmt.Println("After Encrypt : ", cipherText)
	decrypt := c.Decrypt(cipherText)
	fmt.Println("After Decrypt : ", decrypt)
}