stringx

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2024 License: MIT Imports: 8 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CutFromLeft

func CutFromLeft(s, sep string) (before, after string, found bool)

CutFromLeft is the same as strings.Cut, which starts from left to right, slices s around the first instance of sep, returning the text before and after sep. The found result reports whether sep appears in s. If sep does not appear in s, cut returns s, "", false.

func CutFromRight

func CutFromRight(s, sep string) (before, after string, found bool)

CutFromRight takes the same arguments as CutFromLeft, but starts from right to left, slices s around the last instance of sep, return the text before and after sep. The found result reports whether sep appears in s. If sep does not appear in s, cut returns s, "", false.

func FromBytes

func FromBytes(b *[]byte) string

FromBytes converts a byte slice to a string.

func RandomBase64 added in v0.6.1

func RandomBase64(n int) string

RandomBase64 generates a random base64 string with length of n, safe for URL.

func RandomBytes added in v0.6.1

func RandomBytes(n int) []byte

RandomBytes generates n random bytes.

func RandomHex added in v0.6.1

func RandomHex(n int) string

RandomHex generates a random hex string with length of n e.g: 67aab2d956bd7cc621af22cfb169cba8.

func RandomString added in v0.6.1

func RandomString(n int, letters ...string) string

RandomString generates a random string using only letters provided in the letters parameter if user omit letters parameters, this function will use defLetters instead.

func SumByFNV64a

func SumByFNV64a(s string, ss ...string) string

SumByFNV64a sums up the string(s) by FNV-64a hash algorithm.

func SumBySHA224

func SumBySHA224(s string, ss ...string) string

SumBySHA224 sums up the string(s) by SHA224 hash algorithm.

func SumBySHA256

func SumBySHA256(s string, ss ...string) string

SumBySHA256 sums up the string(s) by SHA256 hash algorithm.

func SumBytesByFNV64a

func SumBytesByFNV64a(bs []byte, bss ...[]byte) string

SumBytesByFNV64a sums up the byte slice(s) by FNV-64a hash algorithm.

func SumBytesBySHA224

func SumBytesBySHA224(bs []byte, bss ...[]byte) string

SumBytesBySHA224 sums up the byte slice(s) by SHA224 hash algorithm.

func SumBytesBySHA256

func SumBytesBySHA256(bs []byte, bss ...[]byte) string

SumBytesBySHA256 sums up the byte slice(s) by SHA256 hash algorithm.

func ToBytes

func ToBytes(s *string) (bs []byte)

ToBytes converts a string to a byte slice, which is impossible to modify the item of slice.

Types

This section is empty.

Jump to

Keyboard shortcuts

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