utils

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2022 License: MIT Imports: 21 Imported by: 0

README

utils

一个golang的工具库

Documentation

Overview

* * Created by GoLand * User: dollarkiller * Date: 19-6-12 * Time: 上午11:53 *

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AESDecrypt

func AESDecrypt(key []byte, ciphertext []byte) ([]byte, bool)

Decrypt from base64 to decrypted string

func AESEncrypt

func AESEncrypt(key []byte, plaintext []byte) ([]byte, bool)

对称加密 AES 高级标准加密 Encrypt string to base64 crypto using AES

func Base64Decode

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

Base64解码

func Base64Encode

func Base64Encode(data []byte) string

Base64编码

func Base64URLDecode

func Base64URLDecode(s string) ([]byte, error)

Base64URL解码

func Base64URLEncode

func Base64URLEncode(data []byte) string

Base64URL编码

func DirPing

func DirPing(path string) error

如果文件夹不存在就会创建

func FielGetSize

func FielGetSize(filename string) int64

获取文件大小

func FileGetMD5

func FileGetMD5(file *os.File) string

获取文件MD5

func FileGetPostfix

func FileGetPostfix(filename string) (string, error)

获取文件后缀

func FileGetRandomName

func FileGetRandomName(postfilx string) string

获得随机文件名 传入postfilx后缀 几乎不会重复

func FileGetSha1

func FileGetSha1(file *os.File) string

获得文件sha1

func FileSaveRenameSimple

func FileSaveRenameSimple(name string, data []byte, path string) (string, error)

保存文件 并从命名 Simple 版本 return: NewName,error

func FileSaveSimple

func FileSaveSimple(name string, data []byte, path string) error

保存文件 return error

func GenRsaKey

func GenRsaKey(bits int) (e error, priKey string, pubKey string)

RSA256 公钥密钥对生成 @params: bits 密钥长度 @returns: private 密钥 @returns: public 公钥

func Md5Encode

func Md5Encode(str string) string

获取md5

func PathExists

func PathExists(path string) (bool, error)

判断文件夹是否存在

func Prepend

func Prepend(sc *[]interface{}, value interface{}) *[]interface{}

往slice前面插入数据 和 append 相反 1.8 版本后可使用泛型来实现 不会就不会 那么痛苦

func RsaDecrypt

func RsaDecrypt(ciphertext, privateKey []byte) ([]byte, error)

Rsa256 解密 @params: ciphertext 加密数据 @Params: prvKey 私钥

func RsaDecryptSimple

func RsaDecryptSimple(ciphertext, privateKey string) (string, error)

Rsa256 解密简单

func RsaEncrypt

func RsaEncrypt(origData, pubKey []byte) ([]byte, error)

Rsa256 加密 @params: origData 原始数据 @Params: pubKey 公钥

func RsaEncryptSimple

func RsaEncryptSimple(origData, pubKey string) (string, error)

Rsa256 加密简单 @params: origData 原始数据 @Params: pubKey 公钥

func RsaSign

func RsaSign(data, prvKey []byte) ([]byte, error)

Rsa256 签名 @params: origData 需要签名的数据 @Params: prvKey 私钥

func RsaSignSimple

func RsaSignSimple(data, prvKey string) (string, error)

Rsa256 签名简单 @params: origData 需要签名的数据 @Params: prvKey 私钥

func RsaSignVer

func RsaSignVer(data, signature, publicKey []byte) error

Rsa256 验签 @params: data 原始数据 @params: signature 签名 @params: publicKey 公钥

func RsaSignVerSimple

func RsaSignVerSimple(data, signature, publicKey string) error

Rsa256 验签简单 @params: data 原始数据 @params: signature 签名 @params: publicKey 公钥

func Sha1Encode

func Sha1Encode(str string) string

获取sha1

func Sha256Encode

func Sha256Encode(str string) string

获取sha256

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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