mirror of
https://github.com/fumiama/tienyik.git
synced 2026-06-27 14:20:31 +08:00
init: add rsa & aes
This commit is contained in:
39
aes_test.go
Normal file
39
aes_test.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package tienyik
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"encoding/binary"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestDecrypt(t *testing.T) {
|
||||
const (
|
||||
aescrypted = "vH40y0ly0DCgEGje5aQSAOQX880RtYMWs08Y46lMI8c="
|
||||
aesplain = "moduleCode=DESKTOP_MSGCENTER"
|
||||
)
|
||||
var (
|
||||
rawkey = []uint32{
|
||||
2004378729, 1936745065, 1933079672, 1970627951,
|
||||
842425958, 1932686949, 1903374648, 1936290669,
|
||||
}
|
||||
key [32]byte
|
||||
)
|
||||
for i, k := range rawkey {
|
||||
binary.BigEndian.PutUint32(key[i*4:(i+1)*4], k)
|
||||
}
|
||||
t.Log(string(key[:])) // wxdispbis8txuueo26ffs2veqs18sism
|
||||
d, err := base64.StdEncoding.DecodeString(aescrypted)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
dat, err := NewTYAES(key[:]).Decrypt(d)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
s := string(dat)
|
||||
t.Log(s)
|
||||
if s != aesplain {
|
||||
t.Fail()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user