diff --git a/README.md b/README.md index 4838a01..4fd39a4 100644 --- a/README.md +++ b/README.md @@ -244,38 +244,103 @@ import "github.com/duke-git/lancet/v2/cryptor" #### Function list: -- [AesEcbEncrypt](https://github.com/duke-git/lancet/blob/main/docs/cryptor.md#AesEcbEncrypt) -- [AesEcbDecrypt](https://github.com/duke-git/lancet/blob/main/docs/cryptor.md#AesEcbDecrypt) -- [AesCbcEncrypt](https://github.com/duke-git/lancet/blob/main/docs/cryptor.md#AesCbcEncrypt) -- [AesCbcDecrypt](https://github.com/duke-git/lancet/blob/main/docs/cryptor.md#AesCbcDecrypt) -- [AesCtrCrypt](https://github.com/duke-git/lancet/blob/main/docs/cryptor.md#AesCtrCrypt) -- [AesCfbEncrypt](https://github.com/duke-git/lancet/blob/main/docs/cryptor.md#AesCfbEncrypt) -- [AesCfbDecrypt](https://github.com/duke-git/lancet/blob/main/docs/cryptor.md#AesCfbDecrypt) -- [AesOfbEncrypt](https://github.com/duke-git/lancet/blob/main/docs/cryptor.md#AesOfbEncrypt) -- [AesOfbDecrypt](https://github.com/duke-git/lancet/blob/main/docs/cryptor.md#AesOfbDecrypt) -- [Base64StdEncode](https://github.com/duke-git/lancet/blob/main/docs/cryptor.md#Base64StdEncode) -- [Base64StdDecode](https://github.com/duke-git/lancet/blob/main/docs/cryptor.md#Base64StdDecode) -- [DesEcbEncrypt](https://github.com/duke-git/lancet/blob/main/docs/cryptor.md#DesEcbEncrypt) -- [DesEcbDecrypt](https://github.com/duke-git/lancet/blob/main/docs/cryptor.md#DesEcbDecrypt) -- [DesCbcEncrypt](https://github.com/duke-git/lancet/blob/main/docs/cryptor.md#DesCbcEncrypt) -- [DesCbcDecrypt](https://github.com/duke-git/lancet/blob/main/docs/cryptor.md#DesCbcDecrypt) -- [DesCtrCrypt](https://github.com/duke-git/lancet/blob/main/docs/cryptor.md#DesCtrCrypt) -- [DesCfbEncrypt](https://github.com/duke-git/lancet/blob/main/docs/cryptor.md#DesCfbEncrypt) -- [DesCfbDecrypt](https://github.com/duke-git/lancet/blob/main/docs/cryptor.md#DesCfbDecrypt) -- [DesOfbEncrypt](https://github.com/duke-git/lancet/blob/main/docs/cryptor.md#DesOfbEncrypt) -- [DesOfbDecrypt](https://github.com/duke-git/lancet/blob/main/docs/cryptor.md#DesOfbDecrypt) -- [HmacMd5](https://github.com/duke-git/lancet/blob/main/docs/cryptor.md#HmacMd5) -- [HmacSha1](https://github.com/duke-git/lancet/blob/main/docs/cryptor.md#HmacSha1) -- [HmacSha256](https://github.com/duke-git/lancet/blob/main/docs/cryptor.md#HmacSha256) -- [HmacSha512](https://github.com/duke-git/lancet/blob/main/docs/cryptor.md#HmacSha512) -- [Md5String](https://github.com/duke-git/lancet/blob/main/docs/cryptor.md#Md5String) -- [Md5File](https://github.com/duke-git/lancet/blob/main/docs/cryptor.md#Md5File) -- [Sha1](https://github.com/duke-git/lancet/blob/main/docs/cryptor.md#Sha1) -- [Sha256](https://github.com/duke-git/lancet/blob/main/docs/cryptor.md#Sha256) -- [Sha512](https://github.com/duke-git/lancet/blob/main/docs/cryptor.md#Sha512) -- [GenerateRsaKey](https://github.com/duke-git/lancet/blob/main/docs/cryptor.md#GenerateRsaKey) -- [RsaEncrypt](https://github.com/duke-git/lancet/blob/main/docs/cryptor.md#RsaEncrypt) -- [RsaDecrypt](https://github.com/duke-git/lancet/blob/main/docs/cryptor.md#RsaDecrypt) +- **AesEcbEncrypt** : encrypt byte slice data with key use AES ECB algorithm. + [[doc](https://github.com/duke-git/lancet/blob/main/docs/cryptor.md#AesEcbEncrypt)] + [[play](https://go.dev/play/p/zI6xsmuQRbn)] +- **AesEcbDecrypt** : decrypt byte slice data with key use AES ECB algorithm. + [[doc](https://github.com/duke-git/lancet/blob/main/docs/cryptor.md#AesEcbDecrypt)] + [[play](https://go.dev/play/p/zI6xsmuQRbn)] +- **AesCbcEncrypt** : encrypt byte slice data with key use AES CBC algorithm. + [[doc](https://github.com/duke-git/lancet/blob/main/docs/cryptor.md#AesCbcEncrypt)] + [[play](https://go.dev/play/p/IOq_g8_lKZD)] +- **AesCbcDecrypt** : decrypt byte slice data with key use AES CBC algorithm. + [[doc](https://github.com/duke-git/lancet/blob/main/docs/cryptor.md#AesCbcDecrypt)] + [[play](https://go.dev/play/p/IOq_g8_lKZD)] +- **AesCtrCrypt** : encrypt/ decrypt byte slice data with key use AES CRC algorithm. + [[doc](https://github.com/duke-git/lancet/blob/main/docs/cryptor.md#AesCtrCrypt)] + [[play](https://go.dev/play/p/SpaZO0-5Nsp)] +- **AesCfbEncrypt** : encrypt byte slice data with key use AES CFB algorithm. + [[doc](https://github.com/duke-git/lancet/blob/main/docs/cryptor.md#AesCfbEncrypt)] + [[play](https://go.dev/play/p/tfkF10B13kH)] +- **AesCfbDecrypt** : decrypt byte slice data with key use AES CFB algorithm. + [[doc](https://github.com/duke-git/lancet/blob/main/docs/cryptor.md#AesCfbDecrypt)] + [[play](https://go.dev/play/p/tfkF10B13kH)] +- **AesOfbEncrypt** : encrypt byte slice data with key use AES OFB algorithm. + [[doc](https://github.com/duke-git/lancet/blob/main/docs/cryptor.md#AesOfbEncrypt)] + [[play](https://go.dev/play/p/VtHxtkUj-3F)] +- **AesOfbDecrypt** : decrypt byte slice data with key use AES OFB algorithm. + [[doc](https://github.com/duke-git/lancet/blob/main/docs/cryptor.md#AesOfbDecrypt)] + [[play](https://go.dev/play/p/VtHxtkUj-3F)] +- **Base64StdEncode** : encode string with base64 encoding. + [[doc](https://github.com/duke-git/lancet/blob/main/docs/cryptor.md#Base64StdEncode)] + [[play](https://go.dev/play/p/VOaUyQUreoK)] +- **Base64StdDecode** : decode string with base64 encoding. + [[doc](https://github.com/duke-git/lancet/blob/main/docs/cryptor.md#Base64StdDecode)] + [[play](https://go.dev/play/p/RWQylnJVgIe)] +- **DesEcbEncrypt** : encrypt byte slice data with key use DES ECB algorithm. + [[doc](https://github.com/duke-git/lancet/blob/main/docs/cryptor.md#DesEcbEncrypt)] + [[play](https://go.dev/play/p/8qivmPeZy4P)] +- **DesEcbDecrypt** : decrypt byte slice data with key use DES ECB algorithm. + [[doc](https://github.com/duke-git/lancet/blob/main/docs/cryptor.md#DesEcbDecrypt)] + [[play](https://go.dev/play/p/8qivmPeZy4P)] +- **DesCbcEncrypt** : encrypt byte slice data with key use DES CBC algorithm. + [[doc](https://github.com/duke-git/lancet/blob/main/docs/cryptor.md#DesCbcEncrypt)] + [[play](https://go.dev/play/p/4cC4QvWfe3_1)] +- **DesCbcDecrypt** : decrypt byte slice data with key use DES CBC algorithm. + [[doc](https://github.com/duke-git/lancet/blob/main/docs/cryptor.md#DesCbcDecrypt)] + [[play](https://go.dev/play/p/4cC4QvWfe3_1)] +- **DesCtrCrypt** : encrypt/decrypt byte slice data with key use DES CRY algorithm. + [[doc](https://github.com/duke-git/lancet/blob/main/docs/cryptor.md#DesCtrCrypt)] + [[play](https://go.dev/play/p/9-T6OjKpcdw)] +- **DesCfbEncrypt** : encrypt byte slice data with key use DES CFB algorithm. + [[doc](https://github.com/duke-git/lancet/blob/main/docs/cryptor.md#DesCfbEncrypt)] + [[play](https://go.dev/play/p/y-eNxcFBlxL)] +- **DesCfbDecrypt** : decrypt byte slice data with key use DES CFB algorithm. + [[doc](https://github.com/duke-git/lancet/blob/main/docs/cryptor.md#DesCfbDecrypt)] + [[play](https://go.dev/play/p/y-eNxcFBlxL)] +- **DesOfbEncrypt** : encrypt byte slice data with key use DES OFB algorithm. + [[doc](https://github.com/duke-git/lancet/blob/main/docs/cryptor.md#DesOfbEncrypt)] + [[play](https://go.dev/play/p/74KmNadjN1J)] +- **DesOfbDecrypt** : decrypt byte slice data with key use DES OFB algorithm. + [[doc](https://github.com/duke-git/lancet/blob/main/docs/cryptor.md#DesOfbDecrypt)] + [[play](https://go.dev/play/p/74KmNadjN1J)] +- **HmacMd5** : return the md5 hmac hash of string. + [[doc](https://github.com/duke-git/lancet/blob/main/docs/cryptor.md#HmacMd5)] + [[play](https://go.dev/play/p/uef0q1fz53I)] +- **HmacSha1** : return the hmac hash of string use sha1. + [[doc](https://github.com/duke-git/lancet/blob/main/docs/cryptor.md#HmacSha1)] + [[play](https://go.dev/play/p/1UI4oQ4WXKM)] +- **HmacSha256** : return the hmac hash of string use sha256. + [[doc](https://github.com/duke-git/lancet/blob/main/docs/cryptor.md#HmacSha256)] + [[play](https://go.dev/play/p/HhpwXxFhhC0)] +- **HmacSha512** : return the hmac hash of string use sha512. + [[doc](https://github.com/duke-git/lancet/blob/main/docs/cryptor.md#HmacSha512)] + [[play](https://go.dev/play/p/59Od6m4A0Ud)] +- **Md5String** : return the md5 value of string. + [[doc](https://github.com/duke-git/lancet/blob/main/docs/cryptor.md#Md5String)] + [[play](https://go.dev/play/p/1bLcVetbTOI)] +- **Md5File** : return the md5 value of file. + [[doc](https://github.com/duke-git/lancet/blob/main/docs/cryptor.md#Md5File)] +- **Sha1** : return the sha1 value (SHA-1 hash algorithm) of string. + [[doc](https://github.com/duke-git/lancet/blob/main/docs/cryptor.md#Sha1)] + [[play](https://go.dev/play/p/_m_uoD1deMT)] +- **Sha256** : return the sha256 value (SHA-256 hash algorithm) of string. + [[doc](https://github.com/duke-git/lancet/blob/main/docs/cryptor.md#Sha256)] + [[play](https://go.dev/play/p/tU9tfBMIAr1)] +- **Sha512** : return the sha512 value (SHA-512 hash algorithm) of string. + [[doc](https://github.com/duke-git/lancet/blob/main/docs/cryptor.md#Sha512)] + [[play](https://go.dev/play/p/3WsvLYZxsHa)] +- **GenerateRsaKey** : create rsa private and public pemo file. + [[doc](https://github.com/duke-git/lancet/blob/main/docs/cryptor.md#GenerateRsaKey)] + [[play](https://go.dev/play/p/zutRHrDqs0X)] +- **RsaEncrypt** : encrypt data with ras algorithm. + [[doc](https://github.com/duke-git/lancet/blob/main/docs/cryptor.md#RsaEncrypt)] + [[play](https://go.dev/play/p/uef0q1fz53I)] +- **RsaDecrypt** : decrypt data with ras algorithm. + [[doc](https://github.com/duke-git/lancet/blob/main/docs/cryptor.md#RsaDecrypt)] + [[play](https://go.dev/play/p/uef0q1fz53I)] + + ### 6. Datetime package supports date and time format and compare. diff --git a/README_zh-CN.md b/README_zh-CN.md index 3d7559f..91d9a21 100644 --- a/README_zh-CN.md +++ b/README_zh-CN.md @@ -243,38 +243,103 @@ import "github.com/duke-git/lancet/v2/cryptor" #### 函数列表: -- [AesEcbEncrypt](https://github.com/duke-git/lancet/blob/main/docs/cryptor_zh-CN.md#AesEcbEncrypt) -- [AesEcbDecrypt](https://github.com/duke-git/lancet/blob/main/docs/cryptor_zh-CN.md#AesEcbDecrypt) -- [AesCbcEncrypt](https://github.com/duke-git/lancet/blob/main/docs/cryptor_zh-CN.md#AesCbcEncrypt) -- [AesCbcDecrypt](https://github.com/duke-git/lancet/blob/main/docs/cryptor_zh-CN.md#AesCbcDecrypt) -- [AesCtrCrypt](https://github.com/duke-git/lancet/blob/main/docs/cryptor_zh-CN.md#AesCtrCrypt) -- [AesCfbEncrypt](https://github.com/duke-git/lancet/blob/main/docs/cryptor_zh-CN.md#AesCfbEncrypt) -- [AesCfbDecrypt](https://github.com/duke-git/lancet/blob/main/docs/cryptor_zh-CN.md#AesCfbDecrypt) -- [AesOfbEncrypt](https://github.com/duke-git/lancet/blob/main/docs/cryptor_zh-CN.md#AesOfbEncrypt) -- [AesOfbDecrypt](https://github.com/duke-git/lancet/blob/main/docs/cryptor_zh-CN.md#AesOfbDecrypt) -- [Base64StdEncode](https://github.com/duke-git/lancet/blob/main/docs/cryptor_zh-CN.md#Base64StdEncode) -- [Base64StdDecode](https://github.com/duke-git/lancet/blob/main/docs/cryptor_zh-CN.md#Base64StdDecode) -- [DesEcbEncrypt](https://github.com/duke-git/lancet/blob/main/docs/cryptor_zh-CN.md#DesEcbEncrypt) -- [DesEcbDecrypt](https://github.com/duke-git/lancet/blob/main/docs/cryptor_zh-CN.md#DesEcbDecrypt) -- [DesCbcEncrypt](https://github.com/duke-git/lancet/blob/main/docs/cryptor_zh-CN.md#DesCbcEncrypt) -- [DesCbcDecrypt](https://github.com/duke-git/lancet/blob/main/docs/cryptor_zh-CN.md#DesCbcDecrypt) -- [DesCtrCrypt](https://github.com/duke-git/lancet/blob/main/docs/cryptor_zh-CN.md#DesCtrCrypt) -- [DesCfbEncrypt](https://github.com/duke-git/lancet/blob/main/docs/cryptor_zh-CN.md#DesCfbEncrypt) -- [DesCfbDecrypt](https://github.com/duke-git/lancet/blob/main/docs/cryptor_zh-CN.md#DesCfbDecrypt) -- [DesOfbEncrypt](https://github.com/duke-git/lancet/blob/main/docs/cryptor_zh-CN.md#DesOfbEncrypt) -- [DesOfbDecrypt](https://github.com/duke-git/lancet/blob/main/docs/cryptor_zh-CN.md#DesOfbDecrypt) -- [HmacMd5](https://github.com/duke-git/lancet/blob/main/docs/cryptor_zh-CN.md#HmacMd5) -- [HmacSha1](https://github.com/duke-git/lancet/blob/main/docs/cryptor_zh-CN.md#HmacSha1) -- [HmacSha256](https://github.com/duke-git/lancet/blob/main/docs/cryptor_zh-CN.md#HmacSha256) -- [HmacSha512](https://github.com/duke-git/lancet/blob/main/docs/cryptor_zh-CN.md#HmacSha512) -- [Md5String](https://github.com/duke-git/lancet/blob/main/docs/cryptor_zh-CN.md#Md5String) -- [Md5File](https://github.com/duke-git/lancet/blob/main/docs/cryptor_zh-CN.md#Md5File) -- [Sha1](https://github.com/duke-git/lancet/blob/main/docs/cryptor_zh-CN.md#Sha1) -- [Sha256](https://github.com/duke-git/lancet/blob/main/docs/cryptor_zh-CN.md#Sha256) -- [Sha512](https://github.com/duke-git/lancet/blob/main/docs/cryptor_zh-CN.md#Sha512) -- [GenerateRsaKey](https://github.com/duke-git/lancet/blob/main/docs/cryptor_zh-CN.md#GenerateRsaKey) -- [RsaEncrypt](https://github.com/duke-git/lancet/blob/main/docs/cryptor_zh-CN.md#RsaEncrypt) -- [RsaDecrypt](https://github.com/duke-git/lancet/blob/main/docs/cryptor_zh-CN.md#RsaDecrypt) +- **AesEcbEncrypt** : 使用AES ECB算法模式加密数据。 + [[doc](https://github.com/duke-git/lancet/blob/main/docs/cryptor_zh-CN.md#AesEcbEncrypt)] + [[play](https://go.dev/play/p/zI6xsmuQRbn)] +- **AesEcbDecrypt** : 使用AES ECB算法模解密数据。 + [[doc](https://github.com/duke-git/lancet/blob/main/docs/cryptor_zh-CN.md#AesEcbDecrypt)] + [[play](https://go.dev/play/p/zI6xsmuQRbn)] +- **AesCbcEncrypt** : 使用AES CBC算法模式加密数据。 + [[doc](https://github.com/duke-git/lancet/blob/main/docs/cryptor_zh-CN.md#AesCbcEncrypt)] + [[play](https://go.dev/play/p/IOq_g8_lKZD)] +- **AesCbcDecrypt** : 使用AES CBC算法模式解密数据。 + [[doc](https://github.com/duke-git/lancet/blob/main/docs/cryptor_zh-CN.md#AesCbcDecrypt)] + [[play](https://go.dev/play/p/IOq_g8_lKZD)] +- **AesCtrCrypt** : 使用AES CTR算法模式加密/解密数据。 + [[doc](https://github.com/duke-git/lancet/blob/main/docs/cryptor_zh-CN.md#AesCtrCrypt)] + [[play](https://go.dev/play/p/SpaZO0-5Nsp)] +- **AesCfbEncrypt** : 使用AES CFB算法模式加密数据。 + [[doc](https://github.com/duke-git/lancet/blob/main/docs/cryptor_zh-CN.md#AesCfbEncrypt)] + [[play](https://go.dev/play/p/tfkF10B13kH)] +- **AesCfbDecrypt** : 使用AES CFB算法模式解密数据。 + [[doc](https://github.com/duke-git/lancet/blob/main/docs/cryptor_zh-CN.md#AesCfbDecrypt)] + [[play](https://go.dev/play/p/tfkF10B13kH)] +- **AesOfbEncrypt** : 使用AES OFB算法模式加密数据。 + [[doc](https://github.com/duke-git/lancet/blob/main/docs/cryptor_zh-CN.md#AesOfbEncrypt)] + [[play](https://go.dev/play/p/VtHxtkUj-3F)] +- **AesOfbDecrypt** : 使用AES OFB算法模式解密数据。 + [[doc](https://github.com/duke-git/lancet/blob/main/docs/cryptor_zh-CN.md#AesOfbDecrypt)] + [[play](https://go.dev/play/p/VtHxtkUj-3F)] +- **Base64StdEncode** : 将字符串base64编码。 + [[doc](https://github.com/duke-git/lancet/blob/main/docs/cryptor_zh-CN.md#Base64StdEncode)] + [[play](https://go.dev/play/p/VOaUyQUreoK)] +- **Base64StdDecode** : 解码base64字符串。 + [[doc](https://github.com/duke-git/lancet/blob/main/docs/cryptor_zh-CN.md#Base64StdDecode)] + [[play](https://go.dev/play/p/RWQylnJVgIe)] +- **DesEcbEncrypt** : 使用DES ECB算法模式加密数据。 + [[doc](https://github.com/duke-git/lancet/blob/main/docs/cryptor_zh-CN.md#DesEcbEncrypt)] + [[play](https://go.dev/play/p/8qivmPeZy4P)] +- **DesEcbDecrypt** : 使用DES ECB算法模解密数据。 + [[doc](https://github.com/duke-git/lancet/blob/main/docs/cryptor_zh-CN.md#DesEcbDecrypt)] + [[play](https://go.dev/play/p/8qivmPeZy4P)] +- **DesCbcEncrypt** : 使用DES CBC算法模式加密数据。 + [[doc](https://github.com/duke-git/lancet/blob/main/docs/cryptor_zh-CN.md#DesCbcEncrypt)] + [[play](https://go.dev/play/p/4cC4QvWfe3_1)] +- **DesCbcDecrypt** : 使用DES CBC算法模式解密数据。 + [[doc](https://github.com/duke-git/lancet/blob/main/docs/cryptor_zh-CN.md#DesCbcDecrypt)] + [[play](https://go.dev/play/p/4cC4QvWfe3_1)] +- **DesCtrCrypt** : 使用DES CTR算法模式加密/解密数据。 + [[doc](https://github.com/duke-git/lancet/blob/main/docs/cryptor_zh-CN.md#DesCtrCrypt)] + [[play](https://go.dev/play/p/9-T6OjKpcdw)] +- **DesCfbEncrypt** : 使用DES CFB算法模式加密数据。 + [[doc](https://github.com/duke-git/lancet/blob/main/docs/cryptor_zh-CN.md#DesCfbEncrypt)] + [[play](https://go.dev/play/p/y-eNxcFBlxL)] +- **DesCfbDecrypt** : 使用DES CFB算法模式解密数据。 + [[doc](https://github.com/duke-git/lancet/blob/main/docs/cryptor_zh-CN.md#DesCfbDecrypt)] + [[play](https://go.dev/play/p/y-eNxcFBlxL)] +- **DesOfbEncrypt** : 使用DES OFB算法模式加密数据。 + [[doc](https://github.com/duke-git/lancet/blob/main/docs/cryptor_zh-CN.md#DesOfbEncrypt)] + [[play](https://go.dev/play/p/74KmNadjN1J)] +- **DesOfbDecrypt** : 使用DES OFB算法模式解密数据。 + [[doc](https://github.com/duke-git/lancet/blob/main/docs/cryptor_zh-CN.md#DesOfbDecrypt)] + [[play](https://go.dev/play/p/74KmNadjN1J)] +- **HmacMd5** : 返回字符串md5 hmac值。 + [[doc](https://github.com/duke-git/lancet/blob/main/docs/cryptor_zh-CN.md#HmacMd5)] + [[play](https://go.dev/play/p/uef0q1fz53I)] +- **HmacSha1** : 返回字符串sha1 hmac值。 + [[doc](https://github.com/duke-git/lancet/blob/main/docs/cryptor_zh-CN.md#HmacSha1)] + [[play](https://go.dev/play/p/1UI4oQ4WXKM)] +- **HmacSha256** : 返回字符串sha256 hmac值。 + [[doc](https://github.com/duke-git/lancet/blob/main/docs/cryptor_zh-CN.md#HmacSha256)] + [[play](https://go.dev/play/p/HhpwXxFhhC0)] +- **HmacSha512** : 返回字符串sha256 hmac值。 + [[doc](https://github.com/duke-git/lancet/blob/main/docs/cryptor_zh-CN.md#HmacSha512)] + [[play](https://go.dev/play/p/59Od6m4A0Ud)] +- **Md5String** : 返回字符串md5值。 + [[doc](https://github.com/duke-git/lancet/blob/main/docs/cryptor_zh-CN.md#Md5String)] + [[play](https://go.dev/play/p/1bLcVetbTOI)] +- **Md5File** : 返回文件md5值。 + [[doc](https://github.com/duke-git/lancet/blob/main/docs/cryptor_zh-CN.md#Md5File)] +- **Sha1** : 返回字符串sha1哈希值。 + [[doc](https://github.com/duke-git/lancet/blob/main/docs/cryptor_zh-CN.md#Sha1)] + [[play](https://go.dev/play/p/_m_uoD1deMT)] +- **Sha256** :返回字符串sha256哈希值。 + [[doc](https://github.com/duke-git/lancet/blob/main/docs/cryptor_zh-CN.md#Sha256)] + [[play](https://go.dev/play/p/tU9tfBMIAr1)] +- **Sha512** : 返回字符串sha512哈希值。 + [[doc](https://github.com/duke-git/lancet/blob/main/docs/cryptor_zh-CN.md#Sha512)] + [[play](https://go.dev/play/p/3WsvLYZxsHa)] +- **GenerateRsaKey** : 在当前目录下创建rsa私钥文件和公钥文件。 + [[doc](https://github.com/duke-git/lancet/blob/main/docs/cryptor_zh-CN.md#GenerateRsaKey)] + [[play](https://go.dev/play/p/zutRHrDqs0X)] +- **RsaEncrypt** : 用公钥文件ras加密数据。 + [[doc](https://github.com/duke-git/lancet/blob/main/docs/cryptor_zh-CN.md#RsaEncrypt)] + [[play](https://go.dev/play/p/uef0q1fz53I)] +- **RsaDecrypt** : 用私钥文件rsa解密数据。 + [[doc](https://github.com/duke-git/lancet/blob/main/docs/cryptor_zh-CN.md#RsaDecrypt)] + [[play](https://go.dev/play/p/uef0q1fz53I)] + + ### 6. datetime 日期时间处理包,格式化日期,比较日期。 diff --git a/cryptor/basic.go b/cryptor/basic.go index 074d257..51e0ad7 100644 --- a/cryptor/basic.go +++ b/cryptor/basic.go @@ -20,20 +20,20 @@ import ( ) // Base64StdEncode encode string with base64 encoding. -// Play: +// Play: https://go.dev/play/p/VOaUyQUreoK func Base64StdEncode(s string) string { return base64.StdEncoding.EncodeToString([]byte(s)) } // Base64StdDecode decode a base64 encoded string. -// Play: +// Play: https://go.dev/play/p/RWQylnJVgIe func Base64StdDecode(s string) string { b, _ := base64.StdEncoding.DecodeString(s) return string(b) } // Md5String return the md5 value of string. -// Play: +// Play: https://go.dev/play/p/1bLcVetbTOI func Md5String(s string) string { h := md5.New() h.Write([]byte(s)) @@ -73,7 +73,7 @@ func Md5File(filename string) (string, error) { } // HmacMd5 return the hmac hash of string use md5. -// Play: +// Play: https://go.dev/play/p/uef0q1fz53I func HmacMd5(data, key string) string { h := hmac.New(md5.New, []byte(key)) h.Write([]byte(data)) @@ -81,7 +81,7 @@ func HmacMd5(data, key string) string { } // HmacSha1 return the hmac hash of string use sha1. -// Play: +// Play: https://go.dev/play/p/1UI4oQ4WXKM func HmacSha1(data, key string) string { h := hmac.New(sha1.New, []byte(key)) h.Write([]byte(data)) @@ -89,7 +89,7 @@ func HmacSha1(data, key string) string { } // HmacSha256 return the hmac hash of string use sha256. -// Play: +// Play: https://go.dev/play/p/HhpwXxFhhC0 func HmacSha256(data, key string) string { h := hmac.New(sha256.New, []byte(key)) h.Write([]byte(data)) @@ -97,7 +97,7 @@ func HmacSha256(data, key string) string { } // HmacSha512 return the hmac hash of string use sha512. -// Play: +// Play: https://go.dev/play/p/59Od6m4A0Ud func HmacSha512(data, key string) string { h := hmac.New(sha512.New, []byte(key)) h.Write([]byte(data)) @@ -105,7 +105,7 @@ func HmacSha512(data, key string) string { } // Sha1 return the sha1 value (SHA-1 hash algorithm) of string. -// Play: +// Play: https://go.dev/play/p/_m_uoD1deMT func Sha1(data string) string { sha1 := sha1.New() sha1.Write([]byte(data)) @@ -113,7 +113,7 @@ func Sha1(data string) string { } // Sha256 return the sha256 value (SHA256 hash algorithm) of string. -// Play: +// Play: https://go.dev/play/p/tU9tfBMIAr1 func Sha256(data string) string { sha256 := sha256.New() sha256.Write([]byte(data)) @@ -121,7 +121,7 @@ func Sha256(data string) string { } // Sha512 return the sha512 value (SHA512 hash algorithm) of string. -// Play: +// Play: https://go.dev/play/p/3WsvLYZxsHa func Sha512(data string) string { sha512 := sha512.New() sha512.Write([]byte(data)) diff --git a/cryptor/encrypt.go b/cryptor/encrypt.go index 4f6af86..6f43cbe 100644 --- a/cryptor/encrypt.go +++ b/cryptor/encrypt.go @@ -279,7 +279,7 @@ func DesCbcDecrypt(encrypted, key []byte) []byte { // DesCtrCrypt encrypt data with key use DES CTR algorithm // len(key) should be 8. -// Play: +// Play: https://go.dev/play/p/9-T6OjKpcdw func DesCtrCrypt(data, key []byte) []byte { block, _ := des.NewCipher(key) @@ -375,8 +375,7 @@ func DesOfbDecrypt(data, key []byte) []byte { return decrypted } -// GenerateRsaKey make a rsa private key, and return key file name -// Generated key file is `rsa_private.pem` and `rsa_public.pem` in current path. +// GenerateRsaKey create rsa private and public pemo file. // Play: https://go.dev/play/p/zutRHrDqs0X func GenerateRsaKey(keySize int, priKeyFile, pubKeyFile string) error { // private key diff --git a/docs/cryptor_zh-CN.md b/docs/cryptor_zh-CN.md index 23c84b3..b144c08 100644 --- a/docs/cryptor_zh-CN.md +++ b/docs/cryptor_zh-CN.md @@ -184,7 +184,7 @@ func main() { ### AesCtrCrypt -

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

+

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

函数签名: