cryptor

package
v0.0.0-...-72bb39b Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2023 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package cryptor implements some util functions to encrypt and decrypt. Note: 1. for aes crypt function, the `key` param length should be 16, 24 or 32. if not, will panic.

Package cryptor implements some util functions to encrypt and decrypt. Contain base64, hmac, sha, aes, des, and rsa

Package cryptor implements some util functions to encrypt and decrypt.

Package cryptor implements some util functions to encrypt and decrypt.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AesCbcDecrypt

func AesCbcDecrypt(data, key []byte) []byte

AesCbcDecrypt decrypted data with key use AES CBC algorithm len(key) should be 16,24 or 32

func AesCbcEncrypt

func AesCbcEncrypt(data, key []byte) []byte

AesCbcEncrypt encrypt data with key use Ars CBC algorithm len(key) should be 16,24 or 32

func AesCfbDecrypt

func AesCfbDecrypt(encrypted, key []byte) []byte

AesCfbDecrypt decrypt data with key use AES CFB algorithm len(encrypted) should be greater than 16, len(key) should be 16,24 or 32

func AesCfbEncrypt

func AesCfbEncrypt(data, key []byte) []byte

AesCfbEncrypt encrypt data with key use AES CFB algorithm len(key) should be 16,24 or 32

func AesCtrCrypt

func AesCtrCrypt(data, key []byte) []byte

AesCtrCrypt encrypt data with key use AES CRT algorithm len(key) should be 16,24 or 32

func AesEcbDecrypt

func AesEcbDecrypt(encrypted, key []byte) []byte

AesEcbDecrypt decrypt data with key use AES ECB algorithm

func AesEcbEncrypt

func AesEcbEncrypt(data, key []byte) []byte

AesEcbEncrypt encrypt data with key use AES ECB algorithm len(key) should be 16,24, or 32

func AesOfbDecrypt

func AesOfbDecrypt(data, key []byte) []byte

AesOfbDecrypt decrypt data with key use AES OFB algorithm len(key) should be 16, 24 or 32

func AesOfbEncrypt

func AesOfbEncrypt(data, key []byte) []byte

AesOfbEncrypt encrypt data with key use AES OFB algorithm len(key) should be 16,24 or 32

func Base64StdDecode

func Base64StdDecode(s string) string

Base64StdDecode decode a base64 encoded string

func Base64StdEncode

func Base64StdEncode(s string) string

Base64StdEncode encode string with base64 encoding

func DesCbcDecrypt

func DesCbcDecrypt(encrypted, key []byte) []byte

DesCbcDecrypt decrypt data with key use DES CBC algorithm len(key) should be 8

func DesCbcEncrypt

func DesCbcEncrypt(data, key []byte) []byte

DesCbcEncrypt encrypt data with key use DES CBC algorithm len(key) should be 8

func DesCfbDecrypt

func DesCfbDecrypt(encrypted []byte, key []byte) []byte

DesCfbDecrypt decrypts data with key use DES CFB algorithm len(encrypted) should be greater than 16,len(key) should be 8

func DesCfbEncrypt

func DesCfbEncrypt(data, key []byte) []byte

DesCfbEncrypt encrypt data with key use DES CFB algorithm len(key) should be 8

func DesCtrCrypt

func DesCtrCrypt(data, key []byte) []byte

DesCtrCrypt encrypt data with key use DES CTR algorithm len(key) should be 8

func DesEcbDecrypt

func DesEcbDecrypt(encrypted []byte, key []byte) []byte

DesEcbDecrypt decrypt data with key use DES ECB algorithm len(key) should be 8

func DesEcbEncrypt

func DesEcbEncrypt(data, key []byte) []byte

DesEcbEncrypt encrypt data with use DES ECB algorithm len(key) should be 8

func DesOfbDecrypt

func DesOfbDecrypt(data, key []byte) []byte

AesOfbDecrypt decrypt data with key use DES OFB algorithm len(key) should be 8

func DesOfbEncrypt

func DesOfbEncrypt(data, key []byte) []byte

DesOfbEncrypt encrypt data with key use DES OFB algorithm len(key) should be 16,24 or 32

func GenerateRsaKey

func GenerateRsaKey(keySize int, priKeyFile, publicKeyFile string) error

GenerateRsaKey make a rsa private key,and return key file name Generated key file is `rsa_private.pem` and `rsa_public.pem` in current path

func HmacMd5

func HmacMd5(data, key string) string

HmacMd5 return the hmac hash of string use md5

func HmacSha1

func HmacSha1(data, key string) string

HmacSha1 return the hmac hash of string use sha1

func HmacSha256

func HmacSha256(data, key string) string

HmacSha256 return the hmac hash of string use sha256

func HmacSha512

func HmacSha512(data, key string) string

HmacSha512 returns the hmac hash of string use sha512

func Md5File

func Md5File(filename string) (string, error)

Md5File return the md5 value of file

func Md5String

func Md5String(s string) string

Md5String return the md5 value of string

func RsaDecrypt

func RsaDecrypt(data []byte, priKeyFileName string) []byte

RsaDecrypt decrypt data with rsa algorithm

func RsaEncrypt

func RsaEncrypt(data []byte, pubKeyFileName string) []byte

RsaEncrypt encrypt data with rsa algorithm

func Sha1

func Sha1(data string) string

Sha1 return the sha1 value (SHA-1 hash algorithm) of string

func Sha256

func Sha256(data string) string

Sha256 return the sha256 value (SHA-256 hash algorithm) of string

func Sha512

func Sha512(data string) string

Sha512 return the sha512 value (SHA-512 hash algorithm) of string

Types

This section is empty.

Jump to

Keyboard shortcuts

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