Skip to content

Latest commit

 

History

History
39 lines (31 loc) · 588 Bytes

File metadata and controls

39 lines (31 loc) · 588 Bytes

Cipher Encryption Decryption

###How to import

import (
	"github.com/gorward/cipher"
)

###Sample Usage

import (
	"fmt"
	"github.com/gorward/cipher"
	"log"
)

func main() {
	key := []byte("thiskeyforuser1234567890") // 32 bytes or 24 characters
	text := []byte("Hi this is the text to be encrypted")

	fmt.Printf("\n%s\n", text)

	ciphertext, err := cipher.Encrypt(key, text)
	if err != nil {
		log.Fatal(err)
	}

	fmt.Printf("\n%0x\n", ciphertext)

	result, err := cipher.Decrypt(key, ciphertext)
	if err != nil {
		log.Fatal(err)
	}

	fmt.Printf("\n%s\n", result)
}