crypto

package
v0.41.8 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2020 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AesCBCDecode

func AesCBCDecode(key, iv, ciphertext []byte) ([]byte, error)

AesCBCDecode .. key: 密钥,长度需要为 16, 24, 或者 32 iv: 向量长度,长度必须为 16 ciphertext: 待解密的内容

func AesCBCDecodeBase64

func AesCBCDecodeBase64(key, iv []byte, ciphertext string) ([]byte, error)

AesCBCDecodeBase64 .. key: 密钥,长度需要为 16, 24, 或者 32 iv: 向量长度,长度必须为 16 ciphertext: 待解密的内容(格式为 base64)

func AesCBCDecodeHex

func AesCBCDecodeHex(key, iv []byte, ciphertext string) ([]byte, error)

AesCBCDecodeHex .. key: 密钥,长度需要为 16, 24, 或者 32 iv: 向量长度,长度必须为 16 ciphertext: 待解密的内容(格式为 hex) eg: ciphertextHex := "ae5d9a1e7e4260832cba80647b1e788d" ciphertextBase64 := "rl2aHn5CYIMsuoBkex54jQ=="

key := []byte("1234567890123456") iv := []byte("1234567890123456")

plaintextHex, _ := AesCBCDecodeHex(key, iv, ciphertextHex)

output: // plaintextHex => abcdefg

func AesCBCEncode

func AesCBCEncode(key, iv, plaintext []byte) ([]byte, error)

AesCBCEncode .. key: 密钥,长度需要为 16, 24, 或者 32 iv: 向量长度,长度必须为 16 plaintext: 待加密的内容

func AesCBCEncodeBase64

func AesCBCEncodeBase64(key, iv, plaintext []byte) (string, error)

AesCBCEncodeBase64 .. key: 密钥,长度需要为 16, 24, 或者 32 iv: 向量长度,长度必须为 16 plaintext: 待加密的内容 return: base64

func AesCBCEncodeHex

func AesCBCEncodeHex(key, iv, plaintext []byte) (string, error)

AesCBCEncodeHex .. key: 密钥,长度需要为 16, 24, 或者 32 iv: 向量长度,长度必须为 16 plaintext: 待加密的内容 return: 16进制 eg: plaintext := []byte("abcdefg")

key := []byte("1234567890123456") iv := []byte("1234567890123456")

ciphertextHex, _ := AesCBCEncodeHex(key, iv, plaintext)

output: ciphertextHex -> ae5d9a1e7e4260832cba80647b1e788d

func Base64Decode

func Base64Decode(str string) ([]byte, error)

Base64Decode base64 解码

func Base64Encode

func Base64Encode(str string) string

Base64Encode base64 编码 eg: Base64Encode("https://www.keylala.cn/json?str=hello world")

-> aHR0cHM6Ly93d3cua2V5bGFsYS5jbi9qc29uP3N0cj1oZWxsbyB3b3JsZA==

func Base64EncodeByte

func Base64EncodeByte(b []byte) string

Base64EncodeByte base64 编码

func HmacMd5

func HmacMd5(str, key string) string

HmacMd5 对指定内容生成信息摘要 eg: HmacMd5("123456", "abcdef")

-> c6bdcc80c381536a3e85f2ee5f71cebb

func HmacMd5Byte

func HmacMd5Byte(b, key []byte) string

HmacMd5Byte 对指定内容生成信息摘要

func HmacSha1

func HmacSha1(str, key string) string

HmacSha1 对指定内容生成信息摘要 eg: HmacSha1("123456", "abcdef")

-> b8466fbb9634771d25d8ddd1242484bdb748b179

func HmacSha1Byte

func HmacSha1Byte(b, key []byte) string

HmacSha1Byte 对指定内容生成信息摘要

func HmacSha256

func HmacSha256(str, key string) string

HmacSha256 对指定内容生成信息摘要 eg: HmacSha256("123456", "abcdef")

-> ec4a11a5568e5cfdb5fbfe7152e8920d7bad864a0645c57fe49046a3e81ec91d

func HmacSha256Byte

func HmacSha256Byte(b, key []byte) string

HmacSha256Byte 对指定内容生成信息摘要

func HmacSha512

func HmacSha512(str, key string) string

HmacSha512 对指定内容生成信息摘要 eg: HmacSha512("123456", "abcdef")

-> 130a4caafb11b798dd7528628d21f742feaad266e66141cc2ac003f0e6437cb57
	49245af8a3018d354e4b55e14703a5966808438afe4aae516d2824b014b5902

func HmacSha512Byte

func HmacSha512Byte(b, key []byte) string

HmacSha512Byte 对指定内容生成信息摘要

func Md5

func Md5(str string) string

Md5 对指定内容生成信息摘要 eg: Md5("123456") -> e10adc3949ba59abbe56e057f20f883e

func Md5Byte

func Md5Byte(b []byte) string

Md5Byte 对指定内容生成信息摘要

func Sha1

func Sha1(str string) string

Sha1 对指定内容生成信息摘要 eg: Sha1("123456") -> 7c4a8d09ca3762af61e59520943dc26494f8941b

func Sha1Byte

func Sha1Byte(b []byte) string

Sha1Byte 对指定内容生成信息摘要

func Sha224

func Sha224(str string) string

Sha224 对指定内容生成信息摘要 eg: Sha224("123456") -> f8cdb04495ded47615258f9dc6a3f4707fd2405434fefc3cbf4ef4e6

func Sha224Byte

func Sha224Byte(b []byte) string

Sha224Byte 对指定内容生成信息摘要

func Sha256

func Sha256(str string) string

Sha256 对指定内容生成信息摘要 eg: Sha256("123456") -> 8d969eef6ecad3c29a3a629280e686cf0c3f5d5a86aff3ca12020c923adc6c92

func Sha256Byte

func Sha256Byte(b []byte) string

Sha256Byte ..

func Sha384

func Sha384(str string) string

Sha384 对指定内容生成信息摘要 eg: Sha384("123456")

	-> 0a989ebc4a77b56a6e2bb7b19d995d185ce44090c13e2984b7ecc6d446d4b61ea9991b76a4c2f04b1
    b4d244841449454

func Sha384Byte

func Sha384Byte(b []byte) string

Sha384Byte 对指定内容生成信息摘要

func Sha512

func Sha512(str string) string

Sha512 对指定内容生成信息摘要 eg: Sha512("123456")

-> ba3253876aed6bc22d4a6ff53d8406c6ad864195ed144ab5c87621b6c233b548baeae6956df346ec8c
   17f5ea10f35ee3cbc514797ed7ddd3145464e2a0bab413

func Sha512Byte

func Sha512Byte(b []byte) string

Sha512Byte 对指定内容生成信息摘要

func URLDecode

func URLDecode(str string) string

URLDecode .. 相当于 JS decodeURIComponent eg: URLDecode(www.keylala.cn%3Fname%3Dalex%26age%3D18%26say%3D%E4%BD%A0%E5%A5%BD)

-> "www.keylala.cn?name=alex&age=18&say=你好"

func URLEncode

func URLEncode(str string) string

URLEncode .. 相当于 JS encodeURIComponent eg: URLEncode("www.keylala.cn?name=alex&age=18&say=你好")

-> "www.keylala.cn%3Fname%3Dalex%26age%3D18%26say%3D%E4%BD%A0%E5%A5%BD"

Types

This section is empty.

Jump to

Keyboard shortcuts

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