rc4

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package rc4 提供 RC4 流密码工具。RC4 已不安全, 仅为兼容旧系统保留,勿用于新系统。

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Apply

func Apply(key string, src []byte) ([]byte, error)

Apply 使用 RC4 对输入执行一次流变换,返回新的结果切片. RC4 是对称流密码,加密与解密是同一操作,统一用 Apply。

func ApplyInPlace

func ApplyInPlace(key string, buf []byte) error

ApplyInPlace 使用 RC4 对输入执行一次流变换,并原地写回结果.

func DecryptBase64ToString

func DecryptBase64ToString(key, cipherText string) (string, error)

DecryptBase64ToString 解码 Base64 后执行 RC4 解密并返回字符串.

func DecryptFromBase64

func DecryptFromBase64(key, cipherText string) ([]byte, error)

DecryptFromBase64 解码 Base64 后执行 RC4 解密.

func EncryptStringToBase64

func EncryptStringToBase64(key, plainText string) (string, error)

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

func EncryptToBase64

func EncryptToBase64(key string, plainText []byte) (string, error)

EncryptToBase64 使用 RC4 加密并编码为 Base64.

Types

This section is empty.

Jump to

Keyboard shortcuts

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