You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
839 B
Go
40 lines
839 B
Go
package stt
|
|
|
|
import "bytes"
|
|
|
|
func Marshal(v any) ([]byte, error) {
|
|
return ConfigDefault.Marshal(v)
|
|
}
|
|
|
|
func Unmarshal(data []byte, v any) error {
|
|
return ConfigDefault.Unmarshal(data, v)
|
|
}
|
|
|
|
func encryptBytes(c []byte, num int) []byte {
|
|
for i := 0; i < num; i++ {
|
|
c = bytes.ReplaceAll(c, []byte{'@'}, []byte("@A"))
|
|
c = bytes.ReplaceAll(c, []byte{'/'}, []byte("@S"))
|
|
}
|
|
|
|
return c
|
|
}
|
|
|
|
func decryptBytes(c []byte, num int) []byte {
|
|
if num == -1 {
|
|
for {
|
|
if bytes.Contains(c, []byte("@S")) || bytes.Contains(c, []byte("@A")) {
|
|
c = bytes.ReplaceAll(c, []byte("@S"), []byte{'/'})
|
|
c = bytes.ReplaceAll(c, []byte("@A"), []byte{'@'})
|
|
} else {
|
|
break
|
|
}
|
|
}
|
|
} else {
|
|
for i := 0; i < num; i++ {
|
|
c = bytes.ReplaceAll(c, []byte("@S"), []byte{'/'})
|
|
c = bytes.ReplaceAll(c, []byte("@A"), []byte{'@'})
|
|
}
|
|
}
|
|
return c
|
|
}
|