public static extern void MDataInfoDecryptNative( IntPtr appPtr, ulong mDataInfoH, IntPtr cipherText, IntPtr cipherLen, IntPtr self, MDataInfoDecryptCb callback);
public static Task <List <byte> > MDataInfoDecryptAsync(ulong mDataInfoH, List <byte> cipherText) { var tcs = new TaskCompletionSource <List <byte> >(); var cipherPtr = cipherText.ToIntPtr(); var cipherLen = (IntPtr)cipherText.Count; MDataInfoDecryptCb callback = null; callback = (pVoid, result, plainText, len) => { if (result.ErrorCode != 0) { tcs.SetException(result.ToException()); CallbackManager.Unregister(callback); return; } var byteList = plainText.ToList <byte>(len); tcs.SetResult(byteList); CallbackManager.Unregister(callback); }; CallbackManager.Register(callback); NativeBindings.MDataInfoDecrypt(Session.AppPtr, mDataInfoH, cipherPtr, cipherLen, Session.UserData, callback); Marshal.FreeHGlobal(cipherPtr); return(tcs.Task); }
public void MDataInfoDecrypt( IntPtr appPtr, ulong mDataInfoH, IntPtr cipherText, IntPtr cipherLen, IntPtr self, MDataInfoDecryptCb callback) { MDataInfoDecryptNative(appPtr, mDataInfoH, cipherText, cipherLen, self, callback); }