gm

package
v0.0.0-...-d62a2a9 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const BlockSize = 16

Variables

This section is empty.

Functions

func CheckPasswd

func CheckPasswd(user, password, encryptPasswd string) (res bool)

CheckPasswd @description: 验证密码 @param: user string 用户名。这里以用户名作为key @param: password string 原始明文密码 @param: encryptPasswd string 加密后的密码(数据库中的密码) @author: GJing @email: gjing1st@gmail.com @date: 2022/12/27 8:58 @success:

func EncryptPasswd

func EncryptPasswd(user, password string) (data string)

EncryptPasswd @description: 加密密码。使用用户名作为key进行加密 @param: user string 用户名。这里以用户名作为key @param: password string 原始明文密码 @author: GJing @email: gjing1st@gmail.com @date: 2022/12/26 20:24 @success:

func New

func New() hash.Hash

创建哈希计算实例

func NewCipher

func NewCipher(key []byte) (cipher.Block, error)

NewCipher creates and returns a new cipher.Block.

func Sm3Sum

func Sm3Sum(data []byte) []byte

func Sm4CFB

func Sm4CFB(key []byte, in []byte, mode bool) (out []byte, err error)

密码反馈模式(Cipher FeedBack (CFB)) https://blog.csdn.net/zy_strive_2012/article/details/102520356 https://blog.csdn.net/sinat_23338865/article/details/72869841

func Sm4Cbc

func Sm4Cbc(key []byte, in []byte, mode bool) (out []byte, err error)

func Sm4Ecb

func Sm4Ecb(key []byte, in []byte, mode bool) (out []byte, err error)

func Sm4OFB

func Sm4OFB(key []byte, in []byte, mode bool) (out []byte, err error)

输出反馈模式(Output feedback, OFB) https://blog.csdn.net/chengqiuming/article/details/82390910 https://blog.csdn.net/sinat_23338865/article/details/72869841

Types

type SM3

type SM3 struct {
	// contains filtered or unexported fields
}

func (*SM3) BlockSize

func (sm3 *SM3) BlockSize() int

BlockSize returns the hash's underlying block size. The Write method must be able to accept any amount of data, but it may operate more efficiently if all writes are a multiple of the block size.

func (*SM3) Reset

func (sm3 *SM3) Reset()

Reset clears the internal state by zeroing bytes in the state buffer. This can be skipped for a newly-created hash state; the default zero-allocated state is correct.

func (*SM3) Size

func (sm3 *SM3) Size() int

Size returns the number of bytes Sum will return.

func (*SM3) Sum

func (sm3 *SM3) Sum(in []byte) []byte

返回SM3哈希算法摘要值 Sum appends the current hash to b and returns the resulting slice. It does not change the underlying hash state.

func (*SM3) Write

func (sm3 *SM3) Write(p []byte) (int, error)

Write (via the embedded io.Writer interface) adds more data to the running hash. It never returns an error.

type SM4Key

type SM4Key []byte

type Sm4Cipher

type Sm4Cipher struct {
	// contains filtered or unexported fields
}

Cipher is an instance of SM4 encryption.

func (*Sm4Cipher) BlockSize

func (c *Sm4Cipher) BlockSize() int

func (*Sm4Cipher) Decrypt

func (c *Sm4Cipher) Decrypt(dst, src []byte)

func (*Sm4Cipher) Encrypt

func (c *Sm4Cipher) Encrypt(dst, src []byte)

Jump to

Keyboard shortcuts

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