Documentation
¶
Overview ¶
Package rc4 提供 RC4 流密码工具。RC4 已不安全, 仅为兼容旧系统保留,勿用于新系统。
Index ¶
- func Apply(key string, src []byte) ([]byte, error)
- func ApplyInPlace(key string, buf []byte) error
- func DecryptBase64ToString(key, cipherText string) (string, error)
- func DecryptFromBase64(key, cipherText string) ([]byte, error)
- func EncryptStringToBase64(key, plainText string) (string, error)
- func EncryptToBase64(key string, plainText []byte) (string, error)
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyInPlace ¶
ApplyInPlace 使用 RC4 对输入执行一次流变换,并原地写回结果.
func DecryptBase64ToString ¶
DecryptBase64ToString 解码 Base64 后执行 RC4 解密并返回字符串.
func DecryptFromBase64 ¶
DecryptFromBase64 解码 Base64 后执行 RC4 解密.
func EncryptStringToBase64 ¶
EncryptStringToBase64 使用 RC4 加密字符串并编码为 Base64.
Example ¶
package main
import (
"fmt"
"github.com/gtkit/encryx/rc4"
)
func main() {
const key = "secret-key"
enc, err := rc4.EncryptStringToBase64(key, "hello-rc4")
if err != nil {
panic(err)
}
dec, err := rc4.DecryptBase64ToString(key, enc)
if err != nil {
panic(err)
}
fmt.Println(dec)
}
Output: hello-rc4
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.