1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-04 12:52:28 +08:00

doc: add new doc for convertor and cryptor

This commit is contained in:
dudaodong
2023-08-25 10:47:16 +08:00
parent 51f166d1d9
commit cf58542b4a
7 changed files with 201 additions and 180 deletions

View File

@@ -67,6 +67,8 @@ export const enConfig: LocaleSpecificConfig<DefaultTheme.Config> = {
{ 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' },
],
},
],

View File

@@ -77,6 +77,8 @@ export const zhConfig: LocaleSpecificConfig<DefaultTheme.Config> = {
{ 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' },
],
},
],

View File

@@ -46,6 +46,8 @@ import (
<div STYLE="page-break-after: always;"></div>
<link rel="stylesheet" type="text/css" href="/styles/api_doc.css">
## 文档
### <span id="ColorHexToRGB">ColorHexToRGB</span>
@@ -58,7 +60,7 @@ import (
func ColorHexToRGB(colorHex string) (red, green, blue int)
```
<b>示例:</b>
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/o7_ft-JCJBV)</span></b>
```go
package main
@@ -89,7 +91,7 @@ func main() {
func ColorRGBToHex(red, green, blue int) string
```
<b>示例:</b>
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/nzKS2Ro87J1)</span></b>
```go
package main
@@ -122,7 +124,7 @@ func main() {
func ToBool(s string) (bool, error)
```
<b>示例:</b>
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/ARht2WnGdIN)</span></b>
```go
package main
@@ -163,7 +165,7 @@ func main() {
func ToBytes(data any) ([]byte, error)
```
<b>示例:</b>
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/fAMXYFDvOvr)</span></b>
```go
package main
@@ -196,7 +198,7 @@ func main() {
func ToChar(s string) []string
```
<b>示例:</b>
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/JJ1SvbFkVdM)</span></b>
```go
package main
@@ -232,7 +234,7 @@ func main() {
func ToChannel[T any](array []T) <-chan T
```
<b>示例:</b>
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/hOx_oYZbAnL)</span></b>
```go
package main
@@ -269,7 +271,7 @@ func main() {
func ToFloat(value any) (float64, error)
```
<b>示例:</b>
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/4YTmPCibqHJ)</span></b>
```go
package main
@@ -314,7 +316,7 @@ func main() {
func ToInt(value any) (int64, error)
```
<b>示例:</b>
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/9_h9vIt-QZ_b)</span></b>
```go
package main
@@ -356,7 +358,7 @@ func main() {
func ToJson(value any) (string, error)
```
<b>示例:</b>
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/2rLIkMmXWvR)</span></b>
```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
```
<b>示例:</b>
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/tVFy7E-t24l)</span></b>
```go
package main
@@ -432,7 +434,7 @@ func main() {
func ToPointer[T any](value T) *T
```
<b>示例:</b>
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/ASf_etHNlw1)</span></b>
```go
package main
@@ -461,7 +463,7 @@ func main() {
func ToString(value any) string
```
<b>示例:</b>
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/nF1zOOslpQq)</span></b>
```go
package main
@@ -509,7 +511,7 @@ func main() {
func StructToMap(value any) (map[string]any, error)
```
<b>示例:</b>
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/KYGYJqNUBOI)</span></b>
```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
```
<b>示例:</b>
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/dmX4Ix5V6Wl)</span></b>
```go
package main
@@ -577,7 +579,7 @@ func main() {
func EncodeByte(data any) ([]byte, error)
```
<b>示例:</b>
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/DVmM1G5JfuP)</span></b>
```go
package main
@@ -606,7 +608,7 @@ func main() {
func DecodeByte(data []byte, target any) error
```
<b>示例:</b>
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/zI6xsmuQRbn)</span></b>
```go
package main
@@ -642,7 +644,7 @@ func main() {
func DeepClone[T any](src T) T
```
<b>示例:</b>
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/j4DP5dquxnk)</span></b>
```go
package main
@@ -706,7 +708,7 @@ func main() {
func CopyProperties[T, U any](dst T, src U) (err error)
```
<b>示例:</b>
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/oZujoB5Sgg5)</span></b>
```go
package main
@@ -785,7 +787,7 @@ func main() {
func ToInterface(v reflect.Value) (value interface{}, ok bool)
```
<b>示例:</b>
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/syqw0-WG7Xd)</span></b>
```go
package main
@@ -820,7 +822,7 @@ func main() {
func Utf8ToGbk(bs []byte) ([]byte, error)
```
<b>示例:</b>
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/9FlIaFLArIL)</span></b>
```go
package main
@@ -854,7 +856,7 @@ func main() {
func GbkToUtf8(bs []byte) ([]byte, error)
```
<b>示例:</b>
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/OphmHCN_9u8)</span></b>
```go
package main

View File

@@ -1,16 +1,18 @@
# Cryptor
cryptor加密包支持数据加密和解密获取md5hash值。支持base64, md5, hmac, aes, des, rsa。
cryptor包包含数据加密和解密功能。支持 base64, md5, hmac, hash, aes, des, rsa。
<div STYLE="page-break-after: always;"></div>
## 源码:
- [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)
<div STYLE="page-break-after: always;"></div>
## 用法:
```go
import (
"github.com/duke-git/lancet/v2/cryptor"
@@ -20,56 +22,56 @@ import (
<div STYLE="page-break-after: always;"></div>
## 目录
- [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)
<div STYLE="page-break-after: always;"></div>
<link rel="stylesheet" type="text/css" href="/styles/api_doc.css">
## 文档
### <span id="AesEcbEncrypt">AesEcbEncrypt</span>
<p>使用AES ECB算法模式加密数据. 参数`key`的长度是16, 24 or 32。</p>
@@ -79,7 +81,8 @@ import (
```go
func AesEcbEncrypt(data, key []byte) []byte
```
<b>示例:</b>
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/zI6xsmuQRbn)</span></b>
```go
package main
@@ -112,7 +115,8 @@ func main() {
```go
func AesEcbDecrypt(encrypted, key []byte) []byte
```
<b>示例:</b>
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/zI6xsmuQRbn)</span></b>
```go
package main
@@ -145,7 +149,8 @@ func main() {
```go
func AesCbcEncrypt(data, key []byte) []byte
```
<b>示例:</b>
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/IOq_g8_lKZD)</span></b>
```go
package main
@@ -179,7 +184,7 @@ func main() {
func AesCbcDecrypt(encrypted, key []byte) []byte
```
<b>示例:</b>
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/IOq_g8_lKZD)</span></b>
```go
package main
@@ -213,7 +218,7 @@ func main() {
func AesCtrCrypt(data, key []byte) []byte
```
<b>示例:</b>
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/SpaZO0-5Nsp)</span></b>
```go
package main
@@ -247,7 +252,7 @@ func main() {
func AesCfbEncrypt(data, key []byte) []byte
```
<b>示例:</b>
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/tfkF10B13kH)</span></b>
```go
package main
@@ -281,7 +286,7 @@ func main() {
func AesCfbDecrypt(encrypted, key []byte) []byte
```
<b>示例:</b>
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/tfkF10B13kH)</span></b>
```go
package main
@@ -315,7 +320,7 @@ func main() {
func AesOfbEncrypt(data, key []byte) []byte
```
<b>示例:</b>
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/VtHxtkUj-3F)</span></b>
```go
package main
@@ -338,6 +343,7 @@ func main() {
// hello
}
```
### <span id="AesCfbDecrypt">AesOfbDecrypt</span>
<p>使用AES OFB算法模式解密数据参数`key`的长度是16, 24 or 32。</p>
@@ -348,7 +354,7 @@ func main() {
func AesOfbDecrypt(encrypted, key []byte) []byte
```
<b>示例:</b>
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/VtHxtkUj-3F)</span></b>
```go
package main
@@ -381,7 +387,8 @@ func main() {
```go
func Base64StdEncode(s string) string
```
<b>示例:</b>
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/VOaUyQUreoK)</span></b>
```go
package main
@@ -399,6 +406,7 @@ func main() {
// aGVsbG8=
}
```
### <span id="Base64StdDecode">Base64StdDecode</span>
<p>解码base64字符串。</p>
@@ -409,7 +417,7 @@ func main() {
func Base64StdDecode(s string) string
```
<b>示例:</b>
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/RWQylnJVgIe)</span></b>
```go
package main
@@ -438,7 +446,7 @@ func main() {
func DesEcbEncrypt(data, key []byte) []byte
```
<b>示例:</b>
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/8qivmPeZy4P)</span></b>
```go
package main
@@ -462,6 +470,7 @@ func main() {
// hello
}
```
### <span id="DesEcbDecrypt">DesEcbDecrypt</span>
<p>使用DES ECB算法模式解决密数据参数`key`的长度是8。</p>
@@ -472,7 +481,7 @@ func main() {
func DesEcbDecrypt(encrypted, key []byte) []byte
```
<b>示例:</b>
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/8qivmPeZy4P)</span></b>
```go
package main
@@ -507,7 +516,7 @@ func main() {
func DesCbcEncrypt(data, key []byte) []byte
```
<b>示例:</b>
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/4cC4QvWfe3_1)</span></b>
```go
package main
@@ -541,7 +550,7 @@ func main() {
func DesCbcDecrypt(encrypted, key []byte) []byte
```
<b>示例:</b>
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/4cC4QvWfe3_1)</span></b>
```go
package main
@@ -564,6 +573,7 @@ func main() {
// hello
}
```
### <span id="DesCtrCrypt">DesCtrCrypt</span>
<p>使用DES CTR算法模式加密/解密数据,参数`key`的长度是8</p>
@@ -574,7 +584,7 @@ func main() {
func DesCtrCrypt(data, key []byte) []byte
```
<b>示例:</b>
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/9-T6OjKpcdw)</span></b>
```go
package main
@@ -608,7 +618,7 @@ func main() {
func DesCfbEncrypt(data, key []byte) []byte
```
<b>示例:</b>
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/y-eNxcFBlxL)</span></b>
```go
package main
@@ -631,6 +641,7 @@ func main() {
// hello
}
```
### <span id="DesCfbDecrypt">DesCfbDecrypt</span>
<p>使用DES CFB算法模式解决密数据参数`key`的长度是8。</p>
@@ -641,7 +652,7 @@ func main() {
func DesCfbDecrypt(encrypted, key []byte) []byte
```
<b>示例:</b>
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/y-eNxcFBlxL)</span></b>
```go
package main
@@ -664,6 +675,7 @@ func main() {
// hello
}
```
### <span id="DesOfbEncrypt">DesOfbEncrypt</span>
<p>使用DES OFB算法模式加密数据参数`key`的长度是8。</p>
@@ -674,7 +686,7 @@ func main() {
func DesOfbEncrypt(data, key []byte) []byte
```
<b>示例:</b>
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/74KmNadjN1J)</span></b>
```go
package main
@@ -697,6 +709,7 @@ func main() {
// hello
}
```
### <span id="DesOfbDecrypt">DesOfbDecrypt</span>
<p>使用DES OFB算法模式解密数据参数`key`的长度是8。</p>
@@ -707,7 +720,7 @@ func main() {
func DesOfbDecrypt(encrypted, key []byte) []byte
```
<b>示例:</b>
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/74KmNadjN1J)</span></b>
```go
package main
@@ -741,7 +754,7 @@ func main() {
func HmacMd5(str, key string) string
```
<b>示例:</b>
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/uef0q1fz53I)</span></b>
```go
package main
@@ -773,7 +786,7 @@ func main() {
func HmacMd5WithBase64(str, key string) string
```
<b>示例:</b>
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/UY0ng2AefFC)</span></b>
```go
package main
@@ -794,6 +807,7 @@ func main() {
// 6DQwbquJLYclJdSRinpjmg==
}
```
### <span id="HmacSha1">HmacSha1</span>
<p>获取字符串的sha1 hmac值。</p>
@@ -804,7 +818,7 @@ func main() {
func HmacSha1(str, key string) string
```
<b>示例:</b>
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/1UI4oQ4WXKM)</span></b>
```go
package main
@@ -836,7 +850,7 @@ func main() {
func HmacSha1WithBase64(str, key string) string
```
<b>例:</b>
<b>例:<span class="run-container">[运行](https://go.dev/play/p/47JmmGrnF7B)</span></b>
```go
package main
@@ -858,7 +872,6 @@ func main() {
}
```
### <span id="HmacSha256">HmacSha256</span>
<p>获取字符串sha256 hmac值。</p>
@@ -869,7 +882,7 @@ func main() {
func HmacSha256(str, key string) string
```
<b>示例:</b>
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/HhpwXxFhhC0)</span></b>
```go
package main
@@ -901,7 +914,7 @@ func main() {
func HmacSha256WithBase64(str, key string) string
```
<b>例:</b>
<b>例:<span class="run-container">[运行](https://go.dev/play/p/EKbkUvPTLwO)</span></b>
```go
package main
@@ -933,7 +946,7 @@ func main() {
func HmacSha512(str, key string) string
```
<b>示例:</b>
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/59Od6m4A0Ud)</span></b>
```go
package main
@@ -965,7 +978,7 @@ func main() {
func HmacSha512WithBase64(str, key string) string
```
<b>例:</b>
<b>例:<span class="run-container">[运行](https://go.dev/play/p/c6dSe3E2ydU)</span></b>
```go
package main
@@ -987,7 +1000,6 @@ func main() {
}
```
### <span id="Md5String">Md5String</span>
<p>获取字符串md5值。</p>
@@ -998,7 +1010,7 @@ func main() {
func Md5String(str string) string
```
<b>示例:</b>
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/1bLcVetbTOI)</span></b>
```go
package main
@@ -1029,7 +1041,7 @@ func main() {
func Md5StringWithBase64(s string) string
```
<b>示例:</b>
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/Tcb-Z7LN2ax)</span></b>
```go
package main
@@ -1058,7 +1070,7 @@ func main() {
func Md5Byte(data []byte) string
```
<b>示例:</b>
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/suraalH8lyC)</span></b>
```go
package main
@@ -1087,7 +1099,7 @@ func main() {
func Md5ByteWithBase64(data []byte) string
```
<b>例:</b>
<b>例:<span class="run-container">[运行](https://go.dev/play/p/Lx4gH7Vdr5_y)</span></b>
```go
package main
@@ -1142,7 +1154,7 @@ func main() {
func Sha1(str string) string
```
<b>示例:</b>
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/_m_uoD1deMT)</span></b>
```go
package main
@@ -1173,7 +1185,7 @@ func main() {
func Sha1WithBase64(str string) string
```
<b>例:</b>
<b>例:<span class="run-container">[运行](https://go.dev/play/p/fSyx-Gl2l2-)</span></b>
```go
package main
@@ -1202,7 +1214,7 @@ func main() {
func Sha256(str string) string
```
<b>示例:</b>
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/tU9tfBMIAr1)</span></b>
```go
package main
@@ -1233,7 +1245,7 @@ func main() {
func Sha256WithBase64(str string) string
```
<b>例:</b>
<b>例:<span class="run-container">[运行](https://go.dev/play/p/85IXJHIal1k)</span></b>
```go
package main
@@ -1262,7 +1274,7 @@ func main() {
func Sha512(str string) string
```
<b>示例:</b>
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/3WsvLYZxsHa)</span></b>
```go
package main
@@ -1293,7 +1305,7 @@ func main() {
func Sha512WithBase64(str string) string
```
<b>例:</b>
<b>例:<span class="run-container">[运行](https://go.dev/play/p/q_fY2rA-k5I)</span></b>
```go
package main
@@ -1322,7 +1334,7 @@ func main() {
func GenerateRsaKey(keySize int, priKeyFile, pubKeyFile string) error
```
<b>示例:</b>
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/zutRHrDqs0X)</span></b>
```go
package main
@@ -1350,7 +1362,7 @@ func main() {
func RsaEncrypt(data []byte, pubKeyFileName string) []byte
```
<b>示例:</b>
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/uef0q1fz53I)</span></b>
```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() {
}
```
### <span id="RsaDecrypt">RsaDecrypt</span>
<p>用私钥文件rsa解密数据。</p>
@@ -1388,7 +1399,7 @@ func main() {
func RsaDecrypt(data []byte, privateKeyFileName string) []byte
```
<b>示例:</b>
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/uef0q1fz53I)</span></b>
```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
}
```
```

View File

@@ -46,6 +46,8 @@ import (
<div STYLE="page-break-after: always;"></div>
<link rel="stylesheet" type="text/css" href="/styles/api_doc.css">
## Documentation
### <span id="ColorHexToRGB">ColorHexToRGB</span>
@@ -58,7 +60,7 @@ import (
func ColorHexToRGB(colorHex string) (red, green, blue int)
```
<b>Example:</b>
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/o7_ft-JCJBV)</span></b>
```go
package main
@@ -89,7 +91,7 @@ func main() {
func ColorRGBToHex(red, green, blue int) string
```
<b>Example:</b>
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/nzKS2Ro87J1)</span></b>
```go
package main
@@ -122,7 +124,7 @@ func main() {
func ToBool(s string) (bool, error)
```
<b>Example:</b>
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/ARht2WnGdIN)</span></b>
```go
package main
@@ -163,7 +165,7 @@ func main() {
func ToBytes(data any) ([]byte, error)
```
<b>Example:</b>
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/fAMXYFDvOvr)</span></b>
```go
package main
@@ -196,7 +198,7 @@ func main() {
func ToChar(s string) []string
```
<b>Example:</b>
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/JJ1SvbFkVdM)</span></b>
```go
package main
@@ -232,7 +234,7 @@ func main() {
func ToChannel[T any](array []T) <-chan T
```
<b>Example:</b>
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/hOx_oYZbAnL)</span></b>
```go
package main
@@ -269,7 +271,7 @@ func main() {
func ToFloat(value any) (float64, error)
```
<b>Example:</b>
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/4YTmPCibqHJ)</span></b>
```go
package main
@@ -314,7 +316,7 @@ func main() {
func ToInt(value any) (int64, error)
```
<b>Example:</b>
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/9_h9vIt-QZ_b)</span></b>
```go
package main
@@ -356,7 +358,7 @@ func main() {
func ToJson(value any) (string, error)
```
<b>Example:</b>
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/2rLIkMmXWvR)</span></b>
```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
```
<b>Example:</b>
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/tVFy7E-t24l)</span></b>
```go
package main
@@ -432,7 +434,7 @@ func main() {
func ToPointer[T any](value T) *T
```
<b>Example:</b>
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/ASf_etHNlw1)</span></b>
```go
package main
@@ -461,7 +463,7 @@ func main() {
func ToString(value any) string
```
<b>Example:</b>
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/nF1zOOslpQq)</span></b>
```go
package main
@@ -509,7 +511,7 @@ func main() {
func StructToMap(value any) (map[string]any, error)
```
<b>Example:</b>
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/KYGYJqNUBOI)</span></b>
```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
```
<b>Example:</b>
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/dmX4Ix5V6Wl)</span></b>
```go
package main
@@ -577,7 +579,7 @@ func main() {
func EncodeByte(data any) ([]byte, error)
```
<b>Example:</b>
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/DVmM1G5JfuP)</span></b>
```go
package main
@@ -606,7 +608,7 @@ func main() {
func DecodeByte(data []byte, target any) error
```
<b>Example:</b>
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/zI6xsmuQRbn)</span></b>
```go
package main
@@ -642,7 +644,7 @@ func main() {
func DeepClone[T any](src T) T
```
<b>Example:</b>
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/j4DP5dquxnk)</span></b>
```go
package main
@@ -706,7 +708,7 @@ func main() {
func CopyProperties[T, U any](dst T, src U) (err error)
```
<b>Example:</b>
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/oZujoB5Sgg5)</span></b>
```go
package main
@@ -785,7 +787,7 @@ func main() {
func ToInterface(v reflect.Value) (value interface{}, ok bool)
```
<b>Example:</b>
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/syqw0-WG7Xd)</span></b>
```go
package main
@@ -820,7 +822,7 @@ func main() {
func Utf8ToGbk(bs []byte) ([]byte, error)
```
<b>Example:</b>
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/9FlIaFLArIL)</span></b>
```go
package main
@@ -854,7 +856,7 @@ func main() {
func GbkToUtf8(bs []byte) ([]byte, error)
```
<b>Example:</b>
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/OphmHCN_9u8)</span></b>
```go
package main

View File

@@ -69,6 +69,8 @@ import (
<div STYLE="page-break-after: always;"></div>
<link rel="stylesheet" type="text/css" href="/styles/api_doc.css">
## Documentation
### <span id="AesEcbEncrypt">AesEcbEncrypt</span>
@@ -80,7 +82,7 @@ import (
```go
func AesEcbEncrypt(data, key []byte) []byte
```
<b>Example:</b>
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/zI6xsmuQRbn)</span></b>
```go
package main
@@ -113,7 +115,7 @@ func main() {
```go
func AesEcbDecrypt(encrypted, key []byte) []byte
```
<b>Example:</b>
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/zI6xsmuQRbn)</span></b>
```go
package main
@@ -146,7 +148,7 @@ func main() {
```go
func AesCbcEncrypt(data, key []byte) []byte
```
<b>Example:</b>
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/IOq_g8_lKZD)</span></b>
```go
package main
@@ -180,7 +182,7 @@ func main() {
func AesCbcDecrypt(encrypted, key []byte) []byte
```
<b>Example:</b>
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/IOq_g8_lKZD)</span></b>
```go
package main
@@ -214,7 +216,7 @@ func main() {
func AesCtrCrypt(data, key []byte) []byte
```
<b>Example:</b>
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/SpaZO0-5Nsp)</span></b>
```go
package main
@@ -248,7 +250,7 @@ func main() {
func AesCfbEncrypt(data, key []byte) []byte
```
<b>Example:</b>
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/tfkF10B13kH)</span></b>
```go
package main
@@ -282,7 +284,7 @@ func main() {
func AesCfbDecrypt(encrypted, key []byte) []byte
```
<b>Example:</b>
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/tfkF10B13kH)</span></b>
```go
package main
@@ -316,7 +318,7 @@ func main() {
func AesOfbEncrypt(data, key []byte) []byte
```
<b>Example:</b>
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/VtHxtkUj-3F)</span></b>
```go
package main
@@ -349,7 +351,7 @@ func main() {
func AesOfbDecrypt(encrypted, key []byte) []byte
```
<b>Example:</b>
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/VtHxtkUj-3F)</span></b>
```go
package main
@@ -382,7 +384,7 @@ func main() {
```go
func Base64StdEncode(s string) string
```
<b>Example:</b>
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/VOaUyQUreoK)</span></b>
```go
package main
@@ -410,7 +412,7 @@ func main() {
func Base64StdDecode(s string) string
```
<b>Example:</b>
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/RWQylnJVgIe)</span></b>
```go
package main
@@ -439,7 +441,7 @@ func main() {
func DesEcbEncrypt(data, key []byte) []byte
```
<b>Example:</b>
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/8qivmPeZy4P)</span></b>
```go
package main
@@ -473,7 +475,7 @@ func main() {
func DesEcbDecrypt(encrypted, key []byte) []byte
```
<b>Example:</b>
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/8qivmPeZy4P)</span></b>
```go
package main
@@ -508,7 +510,7 @@ func main() {
func DesCbcEncrypt(data, key []byte) []byte
```
<b>Example:</b>
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/4cC4QvWfe3_1)</span></b>
```go
package main
@@ -542,7 +544,7 @@ func main() {
func DesCbcDecrypt(encrypted, key []byte) []byte
```
<b>Example:</b>
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/4cC4QvWfe3_1)</span></b>
```go
package main
@@ -575,7 +577,7 @@ func main() {
func DesCtrCrypt(data, key []byte) []byte
```
<b>Example:</b>
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/9-T6OjKpcdw)</span></b>
```go
package main
@@ -609,7 +611,7 @@ func main() {
func DesCfbEncrypt(data, key []byte) []byte
```
<b>Example:</b>
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/y-eNxcFBlxL)</span></b>
```go
package main
@@ -642,7 +644,7 @@ func main() {
func DesCfbDecrypt(encrypted, key []byte) []byte
```
<b>Example:</b>
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/y-eNxcFBlxL)</span></b>
```go
package main
@@ -675,7 +677,7 @@ func main() {
func DesOfbEncrypt(data, key []byte) []byte
```
<b>Example:</b>
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/74KmNadjN1J)</span></b>
```go
package main
@@ -708,7 +710,7 @@ func main() {
func DesOfbDecrypt(encrypted, key []byte) []byte
```
<b>Example:</b>
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/74KmNadjN1J)</span></b>
```go
package main
@@ -742,7 +744,7 @@ func main() {
func HmacMd5(str, key string) string
```
<b>Example:</b>
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/uef0q1fz53I)</span></b>
```go
package main
@@ -774,7 +776,7 @@ func main() {
func HmacMd5WithBase64(str, key string) string
```
<b>Example:</b>
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/UY0ng2AefFC)</span></b>
```go
package main
@@ -806,7 +808,7 @@ func main() {
func HmacSha1(str, key string) string
```
<b>Example:</b>
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/1UI4oQ4WXKM)</span></b>
```go
package main
@@ -838,7 +840,7 @@ func main() {
func HmacSha1WithBase64(str, key string) string
```
<b>Example:</b>
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/47JmmGrnF7B)</span></b>
```go
package main
@@ -870,7 +872,7 @@ func main() {
func HmacSha256(str, key string) string
```
<b>Example:</b>
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/HhpwXxFhhC0)</span></b>
```go
package main
@@ -902,7 +904,7 @@ func main() {
func HmacSha256WithBase64(str, key string) string
```
<b>Example:</b>
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/EKbkUvPTLwO)</span></b>
```go
package main
@@ -934,7 +936,7 @@ func main() {
func HmacSha512(str, key string) string
```
<b>Example:</b>
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/59Od6m4A0Ud)</span></b>
```go
package main
@@ -966,7 +968,7 @@ func main() {
func HmacSha512WithBase64(str, key string) string
```
<b>Example:</b>
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/c6dSe3E2ydU)</span></b>
```go
package main
@@ -999,7 +1001,7 @@ func main() {
func Md5String(s string) string
```
<b>Example:</b>
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/1bLcVetbTOI)</span></b>
```go
package main
@@ -1030,7 +1032,7 @@ func main() {
func Md5StringWithBase64(s string) string
```
<b>Example:</b>
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/Tcb-Z7LN2ax)</span></b>
```go
package main
@@ -1059,7 +1061,7 @@ func main() {
func Md5Byte(data []byte) string
```
<b>Example:</b>
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/suraalH8lyC)</span></b>
```go
package main
@@ -1088,7 +1090,7 @@ func main() {
func Md5ByteWithBase64(data []byte) string
```
<b>Example:</b>
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/Lx4gH7Vdr5_y)</span></b>
```go
package main
@@ -1143,7 +1145,7 @@ func main() {
func Sha1(str string) string
```
<b>Example:</b>
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/_m_uoD1deMT)</span></b>
```go
package main
@@ -1174,7 +1176,7 @@ func main() {
func Sha1WithBase64(str string) string
```
<b>Example:</b>
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/fSyx-Gl2l2-)</span></b>
```go
package main
@@ -1203,7 +1205,7 @@ func main() {
func Sha256(str string) string
```
<b>Example:</b>
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/tU9tfBMIAr1)</span></b>
```go
package main
@@ -1234,7 +1236,7 @@ func main() {
func Sha256WithBase64(str string) string
```
<b>Example:</b>
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/85IXJHIal1k)</span></b>
```go
package main
@@ -1263,7 +1265,7 @@ func main() {
func Sha512(str string) string
```
<b>Example:</b>
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/3WsvLYZxsHa)</span></b>
```go
package main
@@ -1294,7 +1296,7 @@ func main() {
func Sha512WithBase64(str string) string
```
<b>Example:</b>
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/q_fY2rA-k5I)</span></b>
```go
package main
@@ -1323,7 +1325,7 @@ func main() {
func GenerateRsaKey(keySize int, priKeyFile, pubKeyFile string) error
```
<b>Example:</b>
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/zutRHrDqs0X)</span></b>
```go
package main
@@ -1351,7 +1353,7 @@ func main() {
func RsaEncrypt(data []byte, pubKeyFileName string) []byte
```
<b>Example:</b>
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/uef0q1fz53I)</span></b>
```go
package main
@@ -1389,7 +1391,7 @@ func main() {
func RsaDecrypt(data []byte, privateKeyFileName string) []byte
```
<b>Example:</b>
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/uef0q1fz53I)</span></b>
```go
package main

View File

@@ -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.