cipher

package module
v0.0.0-...-ff3cfa8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 30, 2022 License: GPL-3.0 Imports: 8 Imported by: 0

README

cipher

A way to encrypt strings in Go

Using md5 for hashing and Galois/Counter Mode for the keys

Usage

go get github.com/gocrazygh/cipher

If you are working outside the GOPATH:

go mod init <module name>

Here's an example:

package main

import (
	"bufio"
	"fmt"
	"os"

	"github.com/gocrazygh/cipher"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)

	fmt.Println("Enter text: ")
	scanner.Scan()
	text := scanner.Text()

	fmt.Println("Enter password:")
	scanner.Scan()
	password := scanner.Text()

	ciphertext := cipher.Encrypt([]byte(text), password)
	fmt.Printf("Encrypted: %x\n", ciphertext)
	plaintext := cipher.Decrypt(ciphertext, password)
	fmt.Printf("Decrypted: %s\n", plaintext)
}

TODO

  • Build decrypt example

Acknowledgement

https://www.thepolyglotdeveloper.com/2018/02/encrypt-decrypt-data-golang-application-crypto-packages/

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateHash

func CreateHash(key string) string

func Decrypt

func Decrypt(data []byte, passphrase string) []byte

func DecryptFile

func DecryptFile(filename string, passphrase string) []byte

func Encrypt

func Encrypt(data []byte, passphrase string) []byte

func EncryptFile

func EncryptFile(filename string, data []byte, passphrase string)

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL