ciphers/base64.go
2022-07-30 18:30:44 +10:00

36 lines
654 B
Go

package ciphers
import (
"encoding/base64"
"strings"
)
func Base64EncRsa(b1 []byte) string {
s1 := base64.StdEncoding.EncodeToString(b1)
s2 := ""
var LEN int = 76
for len(s1) > 76 {
s2 = s2 + s1[:LEN] + "\n"
s1 = s1[LEN:]
}
s2 = s2 + s1
return s2
}
func Base64DecRsa(s1 string) ([]byte, error) {
s1 = strings.Replace(s1, "\n", "", -1)
s1 = strings.Replace(s1, "\r", "", -1)
s1 = strings.Replace(s1, " ", "", -1)
return base64.StdEncoding.DecodeString(s1)
}
func Base64Enc(b1 []byte) string {
return base64.StdEncoding.EncodeToString(b1)
}
func Base64Dec(s1 string) ([]byte, error) {
return base64.StdEncoding.DecodeString(s1)
}