I wonder why using msgpack do not encrypt in php.
I think "{"id":1,"v1":"bla","v2":"foo"}" will convert to hex string "83 a2 69 64 01 a2 76 31 a3 62 6c 61 a2 76 32 a3 66 6f 6f"
But the result is "魷"id":1,"v1":"bla","v2":"foo"}" why?
This is my code below:
include_once "msgpack.php";
$phpVariable = array( "id"=>1, "v1"=>'bla',"v2"=> 'foo');
$json = json_encode($phpVariable,true);
echo $json."<br>";//{"id":1,"v1":"bla","v2":"foo"}
$binaryString = msgpack_pack($json);
echo $binaryString."<br>";//魷"id":1,"v1":"bla","v2":"foo"}
$base64 = base64_encode($binaryString);
echo $base64."<br>";//vnsiaWQiOjEsInYxIjoiYmxhIiwidjIiOiJmb28ifQ==
------------output-----------------------
{"id":1,"v1":"bla","v2":"foo"}
魷"id":1,"v1":"bla","v2":"foo"}
vnsiaWQiOjEsInYxIjoiYmxhIiwidjIiOiJmb28ifQ==
If I only use php msgpack,don't use json_encode, but I don't know how to convert decodedBytes in Unity3d C#.
//php code
$data = (object) array('name' => 'peter', 'age' => '30');//this could be a multi array
$msgpack_response = msgpack_pack($data);
$msgpack_response = base64_encode($msgpack_response);
echo $msgpack_response;
//Unity3d C# use msgpack
byte[] decodedBytes = Convert.FromBase64String (text);
ObjectPacker packer = new ObjectPacker ();
??? data = packer.Unpack<???>(decodedBytes);//I don't know the type and how to convert?