gomysqlaes

package module
v0.0.0-...-51a6dcf Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2024 License: MIT Imports: 5 Imported by: 1

README

Simple MySQL AES_ENCRYPT() and AES_DECRYPT() in golang

Installation

go get -u github.com/allape/gomysqlaes

Example

package main

import (
	"fmt"
	"github.com/allape/gomysqlaes"
)

const MyLittleTinyTeenySecret = "plain"
const Password = "12345678"

func main() {
	hex, err := gomysqlaes.EncryptToHex(MyLittleTinyTeenySecret, Password)
	if err != nil {
		panic(err)
	}
	fmt.Println(hex)

	plain, err := gomysqlaes.DecryptFromHex(hex, Password)
	if err != nil {
		panic(err)
	}
	fmt.Println(plain)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decrypt

func Decrypt(data, password []byte) ([]byte, error)

func Encrypt

func Encrypt(plain, password []byte) ([]byte, error)

func FillZero

func FillZero(length int) []byte

func NewBlock

func NewBlock(password []byte) (cipher.Block, error)

func NewPassword

func NewPassword(password []byte, length int) []byte

Types

type HexString

type HexString = string

func DecryptFromHex

func DecryptFromHex(encryptedHex, password string) (HexString, error)

func EncryptToHex

func EncryptToHex(plain, password string) (HexString, error)

Jump to

Keyboard shortcuts

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