diff --git a/docs/.vitepress/en.ts b/docs/.vitepress/en.ts index 498cb34..d8b6f56 100644 --- a/docs/.vitepress/en.ts +++ b/docs/.vitepress/en.ts @@ -67,6 +67,8 @@ export const enConfig: LocaleSpecificConfig = { { text: 'compare', link: '/en/api/packages/compare' }, { text: 'concurrency', link: '/en/api/packages/concurrency' }, { text: 'condition', link: '/en/api/packages/condition' }, + { text: 'convertor', link: '/en/api/packages/convertor' }, + { text: 'cryptor', link: '/en/api/packages/cryptor' }, ], }, ], diff --git a/docs/.vitepress/zh.ts b/docs/.vitepress/zh.ts index 6a8ea07..c841fab 100644 --- a/docs/.vitepress/zh.ts +++ b/docs/.vitepress/zh.ts @@ -77,6 +77,8 @@ export const zhConfig: LocaleSpecificConfig = { { text: '比较器', link: '/api/packages/compare' }, { text: '并发处理', link: '/api/packages/concurrency' }, { text: '条件判断', link: '/api/packages/condition' }, + { text: '类型转换', link: '/api/packages/convertor' }, + { text: '加密&解密', link: '/api/packages/cryptor' }, ], }, ], diff --git a/docs/olddocs/convertor_zh-CN.md b/docs/api/packages/convertor.md similarity index 87% rename from docs/olddocs/convertor_zh-CN.md rename to docs/api/packages/convertor.md index 0a51f48..a27423b 100644 --- a/docs/olddocs/convertor_zh-CN.md +++ b/docs/api/packages/convertor.md @@ -46,6 +46,8 @@ import (
+ + ## 文档 ### ColorHexToRGB @@ -58,7 +60,7 @@ import ( func ColorHexToRGB(colorHex string) (red, green, blue int) ``` -示例: +示例:[运行](https://go.dev/play/p/o7_ft-JCJBV) ```go package main @@ -89,7 +91,7 @@ func main() { func ColorRGBToHex(red, green, blue int) string ``` -示例: +示例:[运行](https://go.dev/play/p/nzKS2Ro87J1) ```go package main @@ -122,7 +124,7 @@ func main() { func ToBool(s string) (bool, error) ``` -示例: +示例:[运行](https://go.dev/play/p/ARht2WnGdIN) ```go package main @@ -163,7 +165,7 @@ func main() { func ToBytes(data any) ([]byte, error) ``` -示例: +示例:[运行](https://go.dev/play/p/fAMXYFDvOvr) ```go package main @@ -196,7 +198,7 @@ func main() { func ToChar(s string) []string ``` -示例: +示例:[运行](https://go.dev/play/p/JJ1SvbFkVdM) ```go package main @@ -232,7 +234,7 @@ func main() { func ToChannel[T any](array []T) <-chan T ``` -示例: +示例:[运行](https://go.dev/play/p/hOx_oYZbAnL) ```go package main @@ -269,7 +271,7 @@ func main() { func ToFloat(value any) (float64, error) ``` -示例: +示例:[运行](https://go.dev/play/p/4YTmPCibqHJ) ```go package main @@ -314,7 +316,7 @@ func main() { func ToInt(value any) (int64, error) ``` -示例: +示例:[运行](https://go.dev/play/p/9_h9vIt-QZ_b) ```go package main @@ -356,7 +358,7 @@ func main() { func ToJson(value any) (string, error) ``` -示例: +示例:[运行](https://go.dev/play/p/2rLIkMmXWvR) ```go package main @@ -391,7 +393,7 @@ func main() { func ToMap[T any, K comparable, V any](array []T, iteratee func(T) (K, V)) map[K]V ``` -示例: +示例:[运行](https://go.dev/play/p/tVFy7E-t24l) ```go package main @@ -432,7 +434,7 @@ func main() { func ToPointer[T any](value T) *T ``` -示例: +示例:[运行](https://go.dev/play/p/ASf_etHNlw1) ```go package main @@ -461,7 +463,7 @@ func main() { func ToString(value any) string ``` -示例: +示例:[运行](https://go.dev/play/p/nF1zOOslpQq) ```go package main @@ -509,7 +511,7 @@ func main() { func StructToMap(value any) (map[string]any, error) ``` -示例: +示例:[运行](https://go.dev/play/p/KYGYJqNUBOI) ```go package main @@ -547,7 +549,7 @@ func main() { func MapToSlice[T any, K comparable, V any](aMap map[K]V, iteratee func(K, V) T) []T ``` -示例: +示例:[运行](https://go.dev/play/p/dmX4Ix5V6Wl) ```go package main @@ -577,7 +579,7 @@ func main() { func EncodeByte(data any) ([]byte, error) ``` -示例: +示例:[运行](https://go.dev/play/p/DVmM1G5JfuP) ```go package main @@ -606,7 +608,7 @@ func main() { func DecodeByte(data []byte, target any) error ``` -示例: +示例:[运行](https://go.dev/play/p/zI6xsmuQRbn) ```go package main @@ -642,7 +644,7 @@ func main() { func DeepClone[T any](src T) T ``` -示例: +示例:[运行](https://go.dev/play/p/j4DP5dquxnk) ```go package main @@ -706,7 +708,7 @@ func main() { func CopyProperties[T, U any](dst T, src U) (err error) ``` -示例: +示例:[运行](https://go.dev/play/p/oZujoB5Sgg5) ```go package main @@ -785,7 +787,7 @@ func main() { func ToInterface(v reflect.Value) (value interface{}, ok bool) ``` -示例: +示例:[运行](https://go.dev/play/p/syqw0-WG7Xd) ```go package main @@ -820,7 +822,7 @@ func main() { func Utf8ToGbk(bs []byte) ([]byte, error) ``` -示例: +示例:[运行](https://go.dev/play/p/9FlIaFLArIL) ```go package main @@ -854,7 +856,7 @@ func main() { func GbkToUtf8(bs []byte) ([]byte, error) ``` -示例: +示例:[运行](https://go.dev/play/p/OphmHCN_9u8) ```go package main diff --git a/docs/olddocs/cryptor_zh-CN.md b/docs/api/packages/cryptor.md similarity index 78% rename from docs/olddocs/cryptor_zh-CN.md rename to docs/api/packages/cryptor.md index 9d2da8c..ba9aa55 100644 --- a/docs/olddocs/cryptor_zh-CN.md +++ b/docs/api/packages/cryptor.md @@ -1,16 +1,18 @@ # Cryptor -cryptor加密包支持数据加密和解密,获取md5,hash值。支持base64, md5, hmac, aes, des, rsa。 + +cryptor包包含数据加密和解密功能。支持 base64, md5, hmac, hash, aes, des, rsa。
## 源码: -- [https://github.com/duke-git/lancet/blob/main/cryptor/basic.go](https://github.com/duke-git/lancet/blob/main/cryptor/basic.go) -- [https://github.com/duke-git/lancet/blob/main/cryptor/crypto.go](https://github.com/duke-git/lancet/blob/main/cryptor/crypto.go) +- [https://github.com/duke-git/lancet/blob/main/cryptor/basic.go](https://github.com/duke-git/lancet/blob/main/cryptor/basic.go) +- [https://github.com/duke-git/lancet/blob/main/cryptor/crypto.go](https://github.com/duke-git/lancet/blob/main/cryptor/crypto.go)
## 用法: + ```go import ( "github.com/duke-git/lancet/v2/cryptor" @@ -20,56 +22,56 @@ import (
## 目录 -- [AesEcbEncrypt](#AesEcbEncrypt) -- [AesEcbDecrypt](#AesEcbDecrypt) -- [AesCbcEncrypt](#AesCbcEncrypt) -- [AesCbcDecrypt](#AesCbcDecrypt) -- [AesCtrCrypt](#AesCtrCrypt) -- [AesCfbEncrypt](#AesCfbEncrypt) -- [AesCfbDecrypt](#AesCfbDecrypt) -- [AesOfbEncrypt](#AesOfbEncrypt) -- [AesOfbDecrypt](#AesOfbDecrypt) -- [Base64StdEncode](#Base64StdEncode) -- [Base64StdDecode](#Base64StdDecode) -- [DesEcbEncrypt](#DesEcbEncrypt) -- [DesEcbDecrypt](#DesEcbDecrypt) -- [DesCbcEncrypt](#DesCbcEncrypt) -- [DesCbcDecrypt](#DesCbcDecrypt) -- [DesCtrCrypt](#DesCtrCrypt) -- [DesCfbEncrypt](#DesCfbEncrypt) -- [DesCfbDecrypt](#DesCfbDecrypt) -- [DesOfbEncrypt](#DesOfbEncrypt) -- [DesOfbDecrypt](#DesOfbDecrypt) -- [HmacMd5](#HmacMd5) -- [HmacMd5WithBase64](#HmacMd5WithBase64) -- [HmacSha1](#HmacSha1) -- [HmacSha1WithBase64](#HmacSha1WithBase64) -- [HmacSha256](#HmacSha256) -- [HmacSha256WithBase64](#HmacSha256WithBase64) -- [HmacSha512](#HmacSha512) -- [HmacSha512WithBase64](#HmacSha512WithBase64) -- [Md5String](#Md5String) -- [Md5StringWithBase64](#Md5StringWithBase64) -- [Md5Byte](#Md5Byte) -- [Md5ByteWithBase64](#Md5ByteWithBase64) -- [Md5File](#Md5File) -- [Sha1](#Sha1) -- [Sha1WithBase64](#Sha1WithBase64) -- [Sha256](#Sha256) -- [Sha256WithBase64](#Sha256WithBase64) -- [Sha512](#Sha512) -- [Sha512WithBase64](#Sha512WithBase64) -- [GenerateRsaKey](#GenerateRsaKey) -- [RsaEncrypt](#RsaEncrypt) -- [RsaDecrypt](#RsaDecrypt) +- [AesEcbEncrypt](#AesEcbEncrypt) +- [AesEcbDecrypt](#AesEcbDecrypt) +- [AesCbcEncrypt](#AesCbcEncrypt) +- [AesCbcDecrypt](#AesCbcDecrypt) +- [AesCtrCrypt](#AesCtrCrypt) +- [AesCfbEncrypt](#AesCfbEncrypt) +- [AesCfbDecrypt](#AesCfbDecrypt) +- [AesOfbEncrypt](#AesOfbEncrypt) +- [AesOfbDecrypt](#AesOfbDecrypt) +- [Base64StdEncode](#Base64StdEncode) +- [Base64StdDecode](#Base64StdDecode) +- [DesEcbEncrypt](#DesEcbEncrypt) +- [DesEcbDecrypt](#DesEcbDecrypt) +- [DesCbcEncrypt](#DesCbcEncrypt) +- [DesCbcDecrypt](#DesCbcDecrypt) +- [DesCtrCrypt](#DesCtrCrypt) +- [DesCfbEncrypt](#DesCfbEncrypt) +- [DesCfbDecrypt](#DesCfbDecrypt) +- [DesOfbEncrypt](#DesOfbEncrypt) +- [DesOfbDecrypt](#DesOfbDecrypt) +- [HmacMd5](#HmacMd5) +- [HmacMd5WithBase64](#HmacMd5WithBase64) +- [HmacSha1](#HmacSha1) +- [HmacSha1WithBase64](#HmacSha1WithBase64) +- [HmacSha256](#HmacSha256) +- [HmacSha256WithBase64](#HmacSha256WithBase64) +- [HmacSha512](#HmacSha512) +- [HmacSha512WithBase64](#HmacSha512WithBase64) +- [Md5String](#Md5String) +- [Md5StringWithBase64](#Md5StringWithBase64) +- [Md5Byte](#Md5Byte) +- [Md5ByteWithBase64](#Md5ByteWithBase64) +- [Md5File](#Md5File) +- [Sha1](#Sha1) +- [Sha1WithBase64](#Sha1WithBase64) +- [Sha256](#Sha256) +- [Sha256WithBase64](#Sha256WithBase64) +- [Sha512](#Sha512) +- [Sha512WithBase64](#Sha512WithBase64) +- [GenerateRsaKey](#GenerateRsaKey) +- [RsaEncrypt](#RsaEncrypt) +- [RsaDecrypt](#RsaDecrypt)
+ + ## 文档 - - ### AesEcbEncrypt

使用AES ECB算法模式加密数据. 参数`key`的长度是16, 24 or 32。

@@ -79,7 +81,8 @@ import ( ```go func AesEcbEncrypt(data, key []byte) []byte ``` -示例: + +示例:[运行](https://go.dev/play/p/zI6xsmuQRbn) ```go package main @@ -112,7 +115,8 @@ func main() { ```go func AesEcbDecrypt(encrypted, key []byte) []byte ``` -示例: + +示例:[运行](https://go.dev/play/p/zI6xsmuQRbn) ```go package main @@ -145,7 +149,8 @@ func main() { ```go func AesCbcEncrypt(data, key []byte) []byte ``` -示例: + +示例:[运行](https://go.dev/play/p/IOq_g8_lKZD) ```go package main @@ -179,7 +184,7 @@ func main() { func AesCbcDecrypt(encrypted, key []byte) []byte ``` -示例: +示例:[运行](https://go.dev/play/p/IOq_g8_lKZD) ```go package main @@ -213,7 +218,7 @@ func main() { func AesCtrCrypt(data, key []byte) []byte ``` -示例: +示例:[运行](https://go.dev/play/p/SpaZO0-5Nsp) ```go package main @@ -247,7 +252,7 @@ func main() { func AesCfbEncrypt(data, key []byte) []byte ``` -示例: +示例:[运行](https://go.dev/play/p/tfkF10B13kH) ```go package main @@ -281,7 +286,7 @@ func main() { func AesCfbDecrypt(encrypted, key []byte) []byte ``` -示例: +示例:[运行](https://go.dev/play/p/tfkF10B13kH) ```go package main @@ -315,7 +320,7 @@ func main() { func AesOfbEncrypt(data, key []byte) []byte ``` -示例: +示例:[运行](https://go.dev/play/p/VtHxtkUj-3F) ```go package main @@ -338,6 +343,7 @@ func main() { // hello } ``` + ### AesOfbDecrypt

使用AES OFB算法模式解密数据,参数`key`的长度是16, 24 or 32。

@@ -348,7 +354,7 @@ func main() { func AesOfbDecrypt(encrypted, key []byte) []byte ``` -示例: +示例:[运行](https://go.dev/play/p/VtHxtkUj-3F) ```go package main @@ -381,7 +387,8 @@ func main() { ```go func Base64StdEncode(s string) string ``` -示例: + +示例:[运行](https://go.dev/play/p/VOaUyQUreoK) ```go package main @@ -399,6 +406,7 @@ func main() { // aGVsbG8= } ``` + ### Base64StdDecode

解码base64字符串。

@@ -409,7 +417,7 @@ func main() { func Base64StdDecode(s string) string ``` -示例: +示例:[运行](https://go.dev/play/p/RWQylnJVgIe) ```go package main @@ -438,7 +446,7 @@ func main() { func DesEcbEncrypt(data, key []byte) []byte ``` -示例: +示例:[运行](https://go.dev/play/p/8qivmPeZy4P) ```go package main @@ -462,6 +470,7 @@ func main() { // hello } ``` + ### DesEcbDecrypt

使用DES ECB算法模式解决密数据,参数`key`的长度是8。

@@ -472,7 +481,7 @@ func main() { func DesEcbDecrypt(encrypted, key []byte) []byte ``` -示例: +示例:[运行](https://go.dev/play/p/8qivmPeZy4P) ```go package main @@ -507,7 +516,7 @@ func main() { func DesCbcEncrypt(data, key []byte) []byte ``` -示例: +示例:[运行](https://go.dev/play/p/4cC4QvWfe3_1) ```go package main @@ -541,7 +550,7 @@ func main() { func DesCbcDecrypt(encrypted, key []byte) []byte ``` -示例: +示例:[运行](https://go.dev/play/p/4cC4QvWfe3_1) ```go package main @@ -564,6 +573,7 @@ func main() { // hello } ``` + ### DesCtrCrypt

使用DES CTR算法模式加密/解密数据,参数`key`的长度是8

@@ -574,7 +584,7 @@ func main() { func DesCtrCrypt(data, key []byte) []byte ``` -示例: +示例:[运行](https://go.dev/play/p/9-T6OjKpcdw) ```go package main @@ -608,7 +618,7 @@ func main() { func DesCfbEncrypt(data, key []byte) []byte ``` -示例: +示例:[运行](https://go.dev/play/p/y-eNxcFBlxL) ```go package main @@ -631,6 +641,7 @@ func main() { // hello } ``` + ### DesCfbDecrypt

使用DES CFB算法模式解决密数据,参数`key`的长度是8。

@@ -641,7 +652,7 @@ func main() { func DesCfbDecrypt(encrypted, key []byte) []byte ``` -示例: +示例:[运行](https://go.dev/play/p/y-eNxcFBlxL) ```go package main @@ -664,6 +675,7 @@ func main() { // hello } ``` + ### DesOfbEncrypt

使用DES OFB算法模式加密数据,参数`key`的长度是8。

@@ -674,7 +686,7 @@ func main() { func DesOfbEncrypt(data, key []byte) []byte ``` -示例: +示例:[运行](https://go.dev/play/p/74KmNadjN1J) ```go package main @@ -697,6 +709,7 @@ func main() { // hello } ``` + ### DesOfbDecrypt

使用DES OFB算法模式解密数据,参数`key`的长度是8。

@@ -707,7 +720,7 @@ func main() { func DesOfbDecrypt(encrypted, key []byte) []byte ``` -示例: +示例:[运行](https://go.dev/play/p/74KmNadjN1J) ```go package main @@ -741,7 +754,7 @@ func main() { func HmacMd5(str, key string) string ``` -示例: +示例:[运行](https://go.dev/play/p/uef0q1fz53I) ```go package main @@ -773,7 +786,7 @@ func main() { func HmacMd5WithBase64(str, key string) string ``` -示例: +示例:[运行](https://go.dev/play/p/UY0ng2AefFC) ```go package main @@ -794,6 +807,7 @@ func main() { // 6DQwbquJLYclJdSRinpjmg== } ``` + ### HmacSha1

获取字符串的sha1 hmac值。

@@ -804,7 +818,7 @@ func main() { func HmacSha1(str, key string) string ``` -示例: +示例:[运行](https://go.dev/play/p/1UI4oQ4WXKM) ```go package main @@ -836,7 +850,7 @@ func main() { func HmacSha1WithBase64(str, key string) string ``` -实例: +示例:[运行](https://go.dev/play/p/47JmmGrnF7B) ```go package main @@ -858,7 +872,6 @@ func main() { } ``` - ### HmacSha256

获取字符串sha256 hmac值。

@@ -869,7 +882,7 @@ func main() { func HmacSha256(str, key string) string ``` -示例: +示例:[运行](https://go.dev/play/p/HhpwXxFhhC0) ```go package main @@ -901,7 +914,7 @@ func main() { func HmacSha256WithBase64(str, key string) string ``` -实例: +示例:[运行](https://go.dev/play/p/EKbkUvPTLwO) ```go package main @@ -933,7 +946,7 @@ func main() { func HmacSha512(str, key string) string ``` -示例: +示例:[运行](https://go.dev/play/p/59Od6m4A0Ud) ```go package main @@ -965,7 +978,7 @@ func main() { func HmacSha512WithBase64(str, key string) string ``` -实例: +示例:[运行](https://go.dev/play/p/c6dSe3E2ydU) ```go package main @@ -987,7 +1000,6 @@ func main() { } ``` - ### Md5String

获取字符串md5值。

@@ -998,7 +1010,7 @@ func main() { func Md5String(str string) string ``` -示例: +示例:[运行](https://go.dev/play/p/1bLcVetbTOI) ```go package main @@ -1029,7 +1041,7 @@ func main() { func Md5StringWithBase64(s string) string ``` -示例: +示例:[运行](https://go.dev/play/p/Tcb-Z7LN2ax) ```go package main @@ -1058,7 +1070,7 @@ func main() { func Md5Byte(data []byte) string ``` -示例: +示例:[运行](https://go.dev/play/p/suraalH8lyC) ```go package main @@ -1087,7 +1099,7 @@ func main() { func Md5ByteWithBase64(data []byte) string ``` -实例: +示例:[运行](https://go.dev/play/p/Lx4gH7Vdr5_y) ```go package main @@ -1142,7 +1154,7 @@ func main() { func Sha1(str string) string ``` -示例: +示例:[运行](https://go.dev/play/p/_m_uoD1deMT) ```go package main @@ -1173,7 +1185,7 @@ func main() { func Sha1WithBase64(str string) string ``` -实例: +示例:[运行](https://go.dev/play/p/fSyx-Gl2l2-) ```go package main @@ -1202,7 +1214,7 @@ func main() { func Sha256(str string) string ``` -示例: +示例:[运行](https://go.dev/play/p/tU9tfBMIAr1) ```go package main @@ -1233,7 +1245,7 @@ func main() { func Sha256WithBase64(str string) string ``` -实例: +示例:[运行](https://go.dev/play/p/85IXJHIal1k) ```go package main @@ -1262,7 +1274,7 @@ func main() { func Sha512(str string) string ``` -示例: +示例:[运行](https://go.dev/play/p/3WsvLYZxsHa) ```go package main @@ -1293,7 +1305,7 @@ func main() { func Sha512WithBase64(str string) string ``` -实例: +示例:[运行](https://go.dev/play/p/q_fY2rA-k5I) ```go package main @@ -1322,7 +1334,7 @@ func main() { func GenerateRsaKey(keySize int, priKeyFile, pubKeyFile string) error ``` -示例: +示例:[运行](https://go.dev/play/p/zutRHrDqs0X) ```go package main @@ -1350,7 +1362,7 @@ func main() { func RsaEncrypt(data []byte, pubKeyFileName string) []byte ``` -示例: +示例:[运行](https://go.dev/play/p/uef0q1fz53I) ```go package main @@ -1365,11 +1377,11 @@ func main() { if err != nil { return } - + data := []byte("hello") encrypted := cryptor.RsaEncrypt(data, "rsa_public.pem") decrypted := cryptor.RsaDecrypt(encrypted, "rsa_private.pem") - + fmt.Println(string(decrypted)) // Output: @@ -1377,7 +1389,6 @@ func main() { } ``` - ### RsaDecrypt

用私钥文件rsa解密数据。

@@ -1388,7 +1399,7 @@ func main() { func RsaDecrypt(data []byte, privateKeyFileName string) []byte ``` -示例: +示例:[运行](https://go.dev/play/p/uef0q1fz53I) ```go package main @@ -1403,14 +1414,14 @@ func main() { if err != nil { return } - + data := []byte("hello") encrypted := cryptor.RsaEncrypt(data, "rsa_public.pem") decrypted := cryptor.RsaDecrypt(encrypted, "rsa_private.pem") - + fmt.Println(string(decrypted)) // Output: // hello } -``` \ No newline at end of file +``` diff --git a/docs/olddocs/convertor.md b/docs/en/api/packages/convertor.md similarity index 88% rename from docs/olddocs/convertor.md rename to docs/en/api/packages/convertor.md index 739662a..fc90175 100644 --- a/docs/olddocs/convertor.md +++ b/docs/en/api/packages/convertor.md @@ -46,6 +46,8 @@ import (
+ + ## Documentation ### ColorHexToRGB @@ -58,7 +60,7 @@ import ( func ColorHexToRGB(colorHex string) (red, green, blue int) ``` -Example: +Example:[Run](https://go.dev/play/p/o7_ft-JCJBV) ```go package main @@ -89,7 +91,7 @@ func main() { func ColorRGBToHex(red, green, blue int) string ``` -Example: +Example:[Run](https://go.dev/play/p/nzKS2Ro87J1) ```go package main @@ -122,7 +124,7 @@ func main() { func ToBool(s string) (bool, error) ``` -Example: +Example:[Run](https://go.dev/play/p/ARht2WnGdIN) ```go package main @@ -163,7 +165,7 @@ func main() { func ToBytes(data any) ([]byte, error) ``` -Example: +Example:[Run](https://go.dev/play/p/fAMXYFDvOvr) ```go package main @@ -196,7 +198,7 @@ func main() { func ToChar(s string) []string ``` -Example: +Example:[Run](https://go.dev/play/p/JJ1SvbFkVdM) ```go package main @@ -232,7 +234,7 @@ func main() { func ToChannel[T any](array []T) <-chan T ``` -Example: +Example:[Run](https://go.dev/play/p/hOx_oYZbAnL) ```go package main @@ -269,7 +271,7 @@ func main() { func ToFloat(value any) (float64, error) ``` -Example: +Example:[Run](https://go.dev/play/p/4YTmPCibqHJ) ```go package main @@ -314,7 +316,7 @@ func main() { func ToInt(value any) (int64, error) ``` -Example: +Example:[Run](https://go.dev/play/p/9_h9vIt-QZ_b) ```go package main @@ -356,7 +358,7 @@ func main() { func ToJson(value any) (string, error) ``` -Example: +Example:[Run](https://go.dev/play/p/2rLIkMmXWvR) ```go package main @@ -391,7 +393,7 @@ func main() { func ToMap[T any, K comparable, V any](array []T, iteratee func(T) (K, V)) map[K]V ``` -Example: +Example:[Run](https://go.dev/play/p/tVFy7E-t24l) ```go package main @@ -432,7 +434,7 @@ func main() { func ToPointer[T any](value T) *T ``` -Example: +Example:[Run](https://go.dev/play/p/ASf_etHNlw1) ```go package main @@ -461,7 +463,7 @@ func main() { func ToString(value any) string ``` -Example: +Example:[Run](https://go.dev/play/p/nF1zOOslpQq) ```go package main @@ -509,7 +511,7 @@ func main() { func StructToMap(value any) (map[string]any, error) ``` -Example: +Example:[Run](https://go.dev/play/p/KYGYJqNUBOI) ```go package main @@ -547,7 +549,7 @@ func main() { func MapToSlice[T any, K comparable, V any](aMap map[K]V, iteratee func(K, V) T) []T ``` -Example: +Example:[Run](https://go.dev/play/p/dmX4Ix5V6Wl) ```go package main @@ -577,7 +579,7 @@ func main() { func EncodeByte(data any) ([]byte, error) ``` -Example: +Example:[Run](https://go.dev/play/p/DVmM1G5JfuP) ```go package main @@ -606,7 +608,7 @@ func main() { func DecodeByte(data []byte, target any) error ``` -Example: +Example:[Run](https://go.dev/play/p/zI6xsmuQRbn) ```go package main @@ -642,7 +644,7 @@ func main() { func DeepClone[T any](src T) T ``` -Example: +Example:[Run](https://go.dev/play/p/j4DP5dquxnk) ```go package main @@ -706,7 +708,7 @@ func main() { func CopyProperties[T, U any](dst T, src U) (err error) ``` -Example: +Example:[Run](https://go.dev/play/p/oZujoB5Sgg5) ```go package main @@ -785,7 +787,7 @@ func main() { func ToInterface(v reflect.Value) (value interface{}, ok bool) ``` -Example: +Example:[Run](https://go.dev/play/p/syqw0-WG7Xd) ```go package main @@ -820,7 +822,7 @@ func main() { func Utf8ToGbk(bs []byte) ([]byte, error) ``` -Example: +Example:[Run](https://go.dev/play/p/9FlIaFLArIL) ```go package main @@ -854,7 +856,7 @@ func main() { func GbkToUtf8(bs []byte) ([]byte, error) ``` -Example: +Example:[Run](https://go.dev/play/p/OphmHCN_9u8) ```go package main diff --git a/docs/olddocs/cryptor.md b/docs/en/api/packages/cryptor.md similarity index 85% rename from docs/olddocs/cryptor.md rename to docs/en/api/packages/cryptor.md index a30a125..083fe37 100644 --- a/docs/olddocs/cryptor.md +++ b/docs/en/api/packages/cryptor.md @@ -69,6 +69,8 @@ import (
+ + ## Documentation ### AesEcbEncrypt @@ -80,7 +82,7 @@ import ( ```go func AesEcbEncrypt(data, key []byte) []byte ``` -Example: +Example:[Run](https://go.dev/play/p/zI6xsmuQRbn) ```go package main @@ -113,7 +115,7 @@ func main() { ```go func AesEcbDecrypt(encrypted, key []byte) []byte ``` -Example: +Example:[Run](https://go.dev/play/p/zI6xsmuQRbn) ```go package main @@ -146,7 +148,7 @@ func main() { ```go func AesCbcEncrypt(data, key []byte) []byte ``` -Example: +Example:[Run](https://go.dev/play/p/IOq_g8_lKZD) ```go package main @@ -180,7 +182,7 @@ func main() { func AesCbcDecrypt(encrypted, key []byte) []byte ``` -Example: +Example:[Run](https://go.dev/play/p/IOq_g8_lKZD) ```go package main @@ -214,7 +216,7 @@ func main() { func AesCtrCrypt(data, key []byte) []byte ``` -Example: +Example:[Run](https://go.dev/play/p/SpaZO0-5Nsp) ```go package main @@ -248,7 +250,7 @@ func main() { func AesCfbEncrypt(data, key []byte) []byte ``` -Example: +Example:[Run](https://go.dev/play/p/tfkF10B13kH) ```go package main @@ -282,7 +284,7 @@ func main() { func AesCfbDecrypt(encrypted, key []byte) []byte ``` -Example: +Example:[Run](https://go.dev/play/p/tfkF10B13kH) ```go package main @@ -316,7 +318,7 @@ func main() { func AesOfbEncrypt(data, key []byte) []byte ``` -Example: +Example:[Run](https://go.dev/play/p/VtHxtkUj-3F) ```go package main @@ -349,7 +351,7 @@ func main() { func AesOfbDecrypt(encrypted, key []byte) []byte ``` -Example: +Example:[Run](https://go.dev/play/p/VtHxtkUj-3F) ```go package main @@ -382,7 +384,7 @@ func main() { ```go func Base64StdEncode(s string) string ``` -Example: +Example:[Run](https://go.dev/play/p/VOaUyQUreoK) ```go package main @@ -410,7 +412,7 @@ func main() { func Base64StdDecode(s string) string ``` -Example: +Example:[Run](https://go.dev/play/p/RWQylnJVgIe) ```go package main @@ -439,7 +441,7 @@ func main() { func DesEcbEncrypt(data, key []byte) []byte ``` -Example: +Example:[Run](https://go.dev/play/p/8qivmPeZy4P) ```go package main @@ -473,7 +475,7 @@ func main() { func DesEcbDecrypt(encrypted, key []byte) []byte ``` -Example: +Example:[Run](https://go.dev/play/p/8qivmPeZy4P) ```go package main @@ -508,7 +510,7 @@ func main() { func DesCbcEncrypt(data, key []byte) []byte ``` -Example: +Example:[Run](https://go.dev/play/p/4cC4QvWfe3_1) ```go package main @@ -542,7 +544,7 @@ func main() { func DesCbcDecrypt(encrypted, key []byte) []byte ``` -Example: +Example:[Run](https://go.dev/play/p/4cC4QvWfe3_1) ```go package main @@ -575,7 +577,7 @@ func main() { func DesCtrCrypt(data, key []byte) []byte ``` -Example: +Example:[Run](https://go.dev/play/p/9-T6OjKpcdw) ```go package main @@ -609,7 +611,7 @@ func main() { func DesCfbEncrypt(data, key []byte) []byte ``` -Example: +Example:[Run](https://go.dev/play/p/y-eNxcFBlxL) ```go package main @@ -642,7 +644,7 @@ func main() { func DesCfbDecrypt(encrypted, key []byte) []byte ``` -Example: +Example:[Run](https://go.dev/play/p/y-eNxcFBlxL) ```go package main @@ -675,7 +677,7 @@ func main() { func DesOfbEncrypt(data, key []byte) []byte ``` -Example: +Example:[Run](https://go.dev/play/p/74KmNadjN1J) ```go package main @@ -708,7 +710,7 @@ func main() { func DesOfbDecrypt(encrypted, key []byte) []byte ``` -Example: +Example:[Run](https://go.dev/play/p/74KmNadjN1J) ```go package main @@ -742,7 +744,7 @@ func main() { func HmacMd5(str, key string) string ``` -Example: +Example:[Run](https://go.dev/play/p/uef0q1fz53I) ```go package main @@ -774,7 +776,7 @@ func main() { func HmacMd5WithBase64(str, key string) string ``` -Example: +Example:[Run](https://go.dev/play/p/UY0ng2AefFC) ```go package main @@ -806,7 +808,7 @@ func main() { func HmacSha1(str, key string) string ``` -Example: +Example:[Run](https://go.dev/play/p/1UI4oQ4WXKM) ```go package main @@ -838,7 +840,7 @@ func main() { func HmacSha1WithBase64(str, key string) string ``` -Example: +Example:[Run](https://go.dev/play/p/47JmmGrnF7B) ```go package main @@ -870,7 +872,7 @@ func main() { func HmacSha256(str, key string) string ``` -Example: +Example:[Run](https://go.dev/play/p/HhpwXxFhhC0) ```go package main @@ -902,7 +904,7 @@ func main() { func HmacSha256WithBase64(str, key string) string ``` -Example: +Example:[Run](https://go.dev/play/p/EKbkUvPTLwO) ```go package main @@ -934,7 +936,7 @@ func main() { func HmacSha512(str, key string) string ``` -Example: +Example:[Run](https://go.dev/play/p/59Od6m4A0Ud) ```go package main @@ -966,7 +968,7 @@ func main() { func HmacSha512WithBase64(str, key string) string ``` -Example: +Example:[Run](https://go.dev/play/p/c6dSe3E2ydU) ```go package main @@ -999,7 +1001,7 @@ func main() { func Md5String(s string) string ``` -Example: +Example:[Run](https://go.dev/play/p/1bLcVetbTOI) ```go package main @@ -1030,7 +1032,7 @@ func main() { func Md5StringWithBase64(s string) string ``` -Example: +Example:[Run](https://go.dev/play/p/Tcb-Z7LN2ax) ```go package main @@ -1059,7 +1061,7 @@ func main() { func Md5Byte(data []byte) string ``` -Example: +Example:[Run](https://go.dev/play/p/suraalH8lyC) ```go package main @@ -1088,7 +1090,7 @@ func main() { func Md5ByteWithBase64(data []byte) string ``` -Example: +Example:[Run](https://go.dev/play/p/Lx4gH7Vdr5_y) ```go package main @@ -1143,7 +1145,7 @@ func main() { func Sha1(str string) string ``` -Example: +Example:[Run](https://go.dev/play/p/_m_uoD1deMT) ```go package main @@ -1174,7 +1176,7 @@ func main() { func Sha1WithBase64(str string) string ``` -Example: +Example:[Run](https://go.dev/play/p/fSyx-Gl2l2-) ```go package main @@ -1203,7 +1205,7 @@ func main() { func Sha256(str string) string ``` -Example: +Example:[Run](https://go.dev/play/p/tU9tfBMIAr1) ```go package main @@ -1234,7 +1236,7 @@ func main() { func Sha256WithBase64(str string) string ``` -Example: +Example:[Run](https://go.dev/play/p/85IXJHIal1k) ```go package main @@ -1263,7 +1265,7 @@ func main() { func Sha512(str string) string ``` -Example: +Example:[Run](https://go.dev/play/p/3WsvLYZxsHa) ```go package main @@ -1294,7 +1296,7 @@ func main() { func Sha512WithBase64(str string) string ``` -Example: +Example:[Run](https://go.dev/play/p/q_fY2rA-k5I) ```go package main @@ -1323,7 +1325,7 @@ func main() { func GenerateRsaKey(keySize int, priKeyFile, pubKeyFile string) error ``` -Example: +Example:[Run](https://go.dev/play/p/zutRHrDqs0X) ```go package main @@ -1351,7 +1353,7 @@ func main() { func RsaEncrypt(data []byte, pubKeyFileName string) []byte ``` -Example: +Example:[Run](https://go.dev/play/p/uef0q1fz53I) ```go package main @@ -1389,7 +1391,7 @@ func main() { func RsaDecrypt(data []byte, privateKeyFileName string) []byte ``` -Example: +Example:[Run](https://go.dev/play/p/uef0q1fz53I) ```go package main diff --git a/docs/en/index.md b/docs/en/index.md index 54c2f15..dd0def9 100644 --- a/docs/en/index.md +++ b/docs/en/index.md @@ -23,7 +23,7 @@ hero: features: - title: Powerful icon: 💪 - details: support 600+ go util functions. eg. string, slice, datetime, net, crypto, concurrency... + details: support 600+ go util functions. inclueds string, slice, datetime, net, crypto, concurrency, etc. - title: Modular by design icon: 🏗 details: Each module is designed as a package with no coupling between modules.