crypto/

directory
v1.0.34 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2022 License: Apache-2.0

README

crypto

基于官方库 crypto 封装的加密组件,目前实现如下功能

  1. hash 算法 md5

    • Md5String(str1) 字符串生成 md5
    • Md5File(file) 文件生成 md5
    • Md5FileByBytes 如果文件很大,可以通过文件大小,生成 md5
  2. hash 算法 sha512

    • Sha512String(str1) 字符串生成 sha512
    • Sha512File(file) 文件生成 sha512
    • Sha512FileByBytes 如果文件很大,可以通过文件大小,生成 sha512
  3. 对称加密算法 (aes 算法 cfb 模式)

    import (
        "git.xiewo.net/go/common/crypto/aes"
    )
    
    a := NewAesCfb("01234567890123456789012345678912")  // 初始化,传入一个 key(只能 16,24,32 位)
    
    clipher, _ := a.EnCrypter("hello, mr laojia! ")                            // 加密
    
    plain, _ := a.DeCrypter("MYPiWPfQyW32s3fmkLnE6L5luO+jcqc2uFGFrRDgyrnWuA==") // 解密
    

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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