sencryption

package
v0.0.0-...-f1241d1 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2024 License: MulanPSL-2.0 Imports: 29 Imported by: 0

Documentation

Overview

Package sencryption provides String related operations

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AesDecrypt

func AesDecrypt(cipherText []byte, key string, iv ...string) (plainText []byte, err error)

AesDecrypt aes decryption

func AesDecryptString

func AesDecryptString(cipherText string, key string, iv ...string) (string,
	error)

AesDecryptString Aes Decrypt to String

func AesEncrypt

func AesEncrypt(plainText []byte, key string, iv ...string) (ciphertext []byte,
	err error)

AesEncrypt aes encryption

func AesEncryptString

func AesEncryptString(plainText string, key string, iv ...string) (string, error)

AesEncryptString Aes Encrypt to String

func AesGCMDecrypt

func AesGCMDecrypt(ciphertext []byte, key string) (plaintext []byte, err error)

func AesGCMDecryptString

func AesGCMDecryptString(cipherText string, key string) (string,
	error)

func AesGCMEncrypt

func AesGCMEncrypt(plaintext []byte, key string) (ciphertext []byte, err error)

func AesGCMEncryptString

func AesGCMEncryptString(plainText string, key string) (string, error)

func Base64Decode

func Base64Decode(data []byte) (value []byte, err error)

func Base64DecodeString

func Base64DecodeString(data string) (value string, err error)

func Base64Encode

func Base64Encode(value []byte) []byte

func Base64EncodeString

func Base64EncodeString(value string) string

func Buffer

func Buffer(size ...int) *strings.Builder

Buffer Buffer

func Bytes2String

func Bytes2String(b []byte) string

Bytes2String bytes to string

func CamelCaseToSnakeCase

func CamelCaseToSnakeCase(str string, delimiter ...string) string

CamelCaseToSnakeCase camelCase To SnakeCase helloWorld/HelloWorld => hello_world

func Expand

func Expand(s string, process func(key string) string) string

func GenRSAKey

func GenRSAKey(bits ...int) (prvkey, pubkey []byte, err error)

GenRSAKey RSA public key private key generation

func Img2Base64

func Img2Base64(path string) (string, error)

Img2Base64 read picture files and convert to base 64 strings

func IsLcfirst

func IsLcfirst(str string) bool

IsLcfirst tests whether the given byte b is in lower case

func IsPattern

func IsPattern(str string) bool

func IsUcfirst

func IsUcfirst(str string) bool

IsUcfirst tests whether the given byte b is in upper case

func Lcfirst

func Lcfirst(str string) string

Lcfirst First letters lowercase

func Len

func Len(str string) int

Len string length (utf8)

func Match

func Match(str, pattern string) bool

func Md5

func Md5(s string) string

func Md5Byte

func Md5Byte(s []byte) string

func Md5File

func Md5File(path string) (encrypt string, err error)

func NewFilter

func NewFilter(words []string, mask ...rune) *filterNode

func NewReplacer

func NewReplacer(mapping map[string]string) *replacer

func PKCS7Padding

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

PKCS7Padding PKCS7 fill mode

func PKCS7UnPadding

func PKCS7UnPadding(origData []byte) ([]byte, error)

PKCS7UnPadding Reverse operation of padding to delete the padding string

func Pad

func Pad(raw string, length int, padStr string, padType PadType) string

Pad String padding

func ParseID

func ParseID(id int64) (t time.Time, ts int64, workerId int64, seq int64)

ParseID reverse uid to timestamp, workid, seq

func ProjectMd5

func ProjectMd5() string

func RSADecrypt

func RSADecrypt(cipherText []byte, privateKey string, bits ...int) ([]byte, error)

RSADecrypt RSA Decrypt

func RSADecryptString

func RSADecryptString(cipherText string, privateKey string) (string, error)

RSADecryptString RSA Decrypt to String

func RSAEncrypt

func RSAEncrypt(plainText []byte, publicKey string, bits ...int) ([]byte, error)

RSAEncrypt RSA Encrypt

func RSAEncryptString

func RSAEncryptString(plainText string, publicKey string) (string, error)

RSAEncryptString RSA Encrypt to String

func RSAKeyDecrypt

func RSAKeyDecrypt(cipherText []byte, privateKey *rsa.PrivateKey, bits ...int) ([]byte, error)

RSAKeyDecrypt RSA Decrypt

func RSAKeyEncrypt

func RSAKeyEncrypt(plainText []byte, publicKey *rsa.PublicKey, bits ...int) ([]byte, error)

RSAKeyEncrypt RSA Encrypt

func RSAPriKeyEncrypt

func RSAPriKeyEncrypt(plainText []byte, privateKey string) ([]byte, error)

RSAPriKeyEncrypt RSA PriKey Encrypt

func RSAPriKeyEncryptString

func RSAPriKeyEncryptString(plainText string, privateKey string) (string, error)

RSAPriKeyEncryptString RSA PriKey Encrypt to String

func RSAPubKeyDecrypt

func RSAPubKeyDecrypt(cipherText []byte, publicKey string) ([]byte, error)

RSAPubKeyDecrypt RSA PubKey Decrypt

func RSAPubKeyDecryptString

func RSAPubKeyDecryptString(cipherText string, publicKey string) (string,
	error)

RSAPubKeyDecryptString RSA PubKey Decrypt to String

func Rand

func Rand(n int, tpl ...string) string

Rand random string of specified length, the second parameter limit can only appear the specified character

func RandInt

func RandInt(min int, max int) int

RandInt random numbers in the specified range

func RandUint32

func RandUint32() uint32

func RandUint32Max

func RandUint32Max(max uint32) uint32

RandUint32Max returns pseudorandom uint32 in the range [0..max)

func RegexExtract

func RegexExtract(pattern string, str string) ([]string, error)

RegexExtract extract matching text

func RegexExtractAll

func RegexExtractAll(pattern string, str string, count ...int) ([][]string, error)

RegexExtractAll extract matching all text

func RegexFind

func RegexFind(pattern string, str string, count int) [][]int

RegexFind return matching position

func RegexMatch

func RegexMatch(pattern string, str string) bool

RegexMatch check for match

func RegexReplace

func RegexReplace(pattern string, str, repl string) (string, error)

RegexReplace replacing matches of the Regexp

func RegexReplaceFunc

func RegexReplaceFunc(pattern string, str string, repl func(string) string) (string, error)

RegexReplaceFunc replacing matches of the Regexp

func RegexSplit

func RegexSplit(pattern string, str string) ([]string, error)

RegexSplit split the string

func Serialize

func Serialize(value interface{}) ([]byte, error)

func SnakeCaseToCamelCase

func SnakeCaseToCamelCase(str string, ucfirst bool, delimiter ...string) string

SnakeCaseToCamelCase snakeCase To CamelCase: hello_world => helloWorld

func String2Bytes

func String2Bytes(s string) []byte

String2Bytes string to bytes remark: read only, the structure of runtime changes will be affected, the role of unsafe.Pointer will be changed, and it will also be affected

func Substr

func Substr(str string, start int, length ...int) string

Substr returns part of a string

func TrimBOM

func TrimBOM(fileBytes []byte) []byte

TrimBOM TrimBOM

func TrimLine

func TrimLine(s string) string

TrimLine TrimLine

func TrimSpace

func TrimSpace(s string) string

TrimSpace TrimSpace

func UUID

func UUID() int64

func Ucfirst

func Ucfirst(str string) string

Ucfirst First letters capitalize

func UnSerialize

func UnSerialize(valueBytes []byte, registers ...interface{}) (value interface{}, err error)

func UniqueID

func UniqueID(n int) string

UniqueID unique id minimum 6 digits

func UrlDecode

func UrlDecode(str string) (string, error)

UrlDecode url decode string

func UrlEncode

func UrlEncode(str string) string

UrlEncode url encode string, is + not %20

func UrlRawDecode

func UrlRawDecode(str string) (string, error)

UrlRawDecode Decode URL-encoded strings.

func UrlRawEncode

func UrlRawEncode(str string) string

UrlRawEncode URL-encode according to RFC 3986.

func WeightedRand

func WeightedRand(choices map[interface{}]uint32) (interface{}, error)

func XSSClean

func XSSClean(str string) string

XSSClean clean html tag

Types

type IDWorker

type IDWorker struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

IDWorker Struct

func NewIDWorker

func NewIDWorker(workerid int64) (iw *IDWorker, err error)

NewIDWorker Generate NewIDWorker with Given workerid

func (*IDWorker) ID

func (iw *IDWorker) ID() (ts int64, err error)

ID Generate next id

type PadType

type PadType uint8
const (
	// PadRight Right padding character
	PadRight PadType = iota
	// PadLeft Left padding character
	PadLeft
	// PadSides Two-sided padding characters,If the two sides are not equal, the right side takes precedence.
	PadSides
)

type Template

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

func NewTemplate

func NewTemplate(template, startTag, endTag string) (*Template, error)

func (*Template) Process

func (t *Template) Process(w io.Writer, fn func(w io.Writer, tag string) (int, error)) (int64, error)

func (*Template) ResetTemplate

func (t *Template) ResetTemplate(template string) error

type Weighteder

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

func NewWeightedRand

func NewWeightedRand(choices map[interface{}]uint32) (*Weighteder, error)

func (*Weighteder) Pick

func (w *Weighteder) Pick() interface{}

Jump to

Keyboard shortcuts

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