Documentation ¶
Index ¶
- func Decrypt(cipherText string, shift int) (plainText string)
- func DecryptWithRawURLBase64(cipherText string, shift int) (plainText string, err error)
- func Encrypt(plainText string, shift int) (cipherText string)
- func EncryptWithRawURLBase64(plainText string, shift int) (cipherText string)
- type CaesarCipher
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecryptWithRawURLBase64 ¶ added in v3.0.24
func Encrypt ¶
Encrypt 凯撒密码加密.
PS: 仅加密大小写的英文字母,不会动中文.
@param shift 推荐值: (1) [1, 25]
(2) 不推荐使用 26*n,因为这样加密了个寂寞
func EncryptWithRawURLBase64 ¶ added in v3.0.24
EncryptWithRawURLBase64 凯撒密码加密 + base64 编码.
PS: (1) base64采用了 base64.RawURLEncoding; (2) 传参 plainText 可以有中文; (3) 返回值可以放到 url 中(但不推荐).
Types ¶
type CaesarCipher ¶
type CaesarCipher struct {
Shift int
}
func NewCaesarCipher ¶
func NewCaesarCipher(shift int) *CaesarCipher
NewCaesarCipher
@param Shift (1) 推荐值: [1, 25]
(2) 不推荐使用 26*n(n >= 0),因为这样加密了个寂寞 (3) 可以是负数,表示向左偏移
func (*CaesarCipher) Decrypt ¶
func (cipher *CaesarCipher) Decrypt(cipherText string) (plainText string)
func (*CaesarCipher) Encrypt ¶
func (cipher *CaesarCipher) Encrypt(plainText string) (cipherText string)
Click to show internal directories.
Click to hide internal directories.