Exemplo n.º 1
0
    public static TssSdk.AntiEncryptResult TssSdkEncrypt(int cmd_id, byte[] src, uint src_len, ref byte[] tar, ref uint tar_len)
    {
        TssSdk.AntiEncryptResult result = TssSdk.AntiEncryptResult.ANTI_NOT_NEED_ENCRYPT;
        GCHandle gCHandle  = GCHandle.Alloc(src, GCHandleType.Pinned);
        GCHandle gCHandle2 = GCHandle.Alloc(tar, GCHandleType.Pinned);

        if (gCHandle.IsAllocated && gCHandle2.IsAllocated)
        {
            TssSdk.EncryptPkgInfo encryptPkgInfo = new TssSdk.EncryptPkgInfo();
            encryptPkgInfo.cmd_id_           = cmd_id;
            encryptPkgInfo.game_pkg_         = gCHandle.AddrOfPinnedObject();
            encryptPkgInfo.game_pkg_len_     = src_len;
            encryptPkgInfo.encrpty_data_     = gCHandle2.AddrOfPinnedObject();
            encryptPkgInfo.encrypt_data_len_ = tar_len;
            result  = TssSdk.tss_sdk_encryptpacket(encryptPkgInfo);
            tar_len = encryptPkgInfo.encrypt_data_len_;
        }
        if (gCHandle.IsAllocated)
        {
            gCHandle.Free();
        }
        if (gCHandle2.IsAllocated)
        {
            gCHandle2.Free();
        }
        return(result);
    }