Beispiel #1
0
func Test_StringHex(t *testing.T) {
	str := "helloworld"
	str1 := common.ToHexString([]byte(str))
	fmt.Println(str1)
	str2 := common.FromHexString(str1)
	fmt.Println(string(str2))
	if str != string(str2) {
		t.Errorf("stringhex failed")
	}
}
Beispiel #2
0
func Test_RC4(t *testing.T) {
	str := "afsfeqrfqgqarfq234esadf123wasd#192.168.13216:8081;192.168.13.216:8081#guid"
	key := "12345678901234567890123456789012"
	tmp1 := common.Rc4Encrypt([]byte(str), key)
	tmp2 := common.ToHexString(tmp1)
	fmt.Println(tmp2)
	tmp3 := common.FromHexString(tmp2)
	tmp4 := common.Rc4Encrypt(tmp3, key)
	if str != string(tmp4) {
		t.Errorf("rc4 failed")
	}
}