edObj

package module
v0.0.0-...-0c5ccfc Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

README

G2EE-加解密对象

  • 更加便捷的进行hash运算处理和加解密处理

支持的hash运算类型

  • 支持MD5,SHA1,SHA256,SHA512
  • 支持HMAC

####哈希运算DEMO

package main
import (
   G2EE_EDOBJ "github.com/ntesicn/g2ee/edObj"
)

func main() {
    edObj := G2EE_EDOBJ.New()
    //需要注意 hash运算的输出类型目前只支持 OutType_HEX 和 OutType_BASE64
    md5Str := edObj.GetHash(edObj.HashType_MD5,"123456",edObj.OutType_HEX)
    fmt.Println(md5Str)
}

加解密

由于精力有限,目前只封装了AES_CBC_128,AES_CBC_192,AES_CBC_256

####AES加解密DEMO

package main
import (
    G2EE_EDOBJ "github.com/ntesicn/g2ee/edObj"
)
func main() {
    edObj := G2EE_EDOBJ.New()
    
    // ecryptType string, input interface{}, secret interface{}, iv interface{}, paddingType string, outType string
    // 这个demo中"123456"为待加密内容  可以传入string 或者[]byte 不用考虑类型转换 直接传入即可
    // demo中"1234567890123456" 为密钥key 可以传入string 或者[]byte 不用考虑类型转换 直接传入即可
    // iv可以直接传入nil 也可以传入指定的偏移量 可以传入string 或者[]byte 不用考虑类型转换 直接传入即可
    // paddingType 为填充类型 edObj.PaddingType_None edObj.PaddingType_PKCS5 edObj.PaddingType_PKCS7 edObj.PaddingType_Zero 
    // outType 为输出类型 edObj.OutType_Hex edObj.OutType_Text edObj.OutType_Binary edObj.OutType_Base64
    aesResult,err := edObj.Encrypt(edObj.AES_CBC_128,"123456","1234567890123456",nil,edObj.PaddingType_PKCS5,edObj.OutType_HEX)
    //aesResult需要根据OutType进行断言
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New() *g2eeEDObject

func PKCS5Padding

func PKCS5Padding(ciphertext []byte, blockSize int) []byte

func PKCS5UnPadding

func PKCS5UnPadding(origData []byte) []byte

func PKCS7Padding

func PKCS7Padding(ciphertext []byte, blocksize int) []byte

func PKCS7UnPadding

func PKCS7UnPadding(origData []byte) []byte

func ZeroPadding

func ZeroPadding(ciphertext []byte, targetSize int) []byte

func ZeroUnPadding

func ZeroUnPadding(origData []byte) []byte

Types

This section is empty.

Jump to

Keyboard shortcuts

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