Example #1
0
        public static Task <List <byte> > Sha3HashAsync(List <byte> source)
        {
            var        tcs       = new TaskCompletionSource <List <byte> >();
            var        sourcePtr = source.ToIntPtr();
            Sha3HashCb callback  = null;

            callback = (pVoid, result, digestPtr, digestLen) => {
                if (result.ErrorCode != 0)
                {
                    tcs.SetException(result.ToException());
                    CallbackManager.Unregister(callback);
                    return;
                }

                tcs.SetResult(digestPtr.ToList <byte>(digestLen));
                CallbackManager.Unregister(callback);
            };

            CallbackManager.Register(callback);
            NativeBindings.Sha3Hash(sourcePtr, (IntPtr)source.Count, Session.UserData, callback);
            Marshal.FreeHGlobal(sourcePtr);

            return(tcs.Task);
        }
Example #2
0
 public static extern void Sha3HashNative(IntPtr data, IntPtr len, IntPtr self, Sha3HashCb callback);
Example #3
0
 public void Sha3Hash(IntPtr data, IntPtr len, IntPtr self, Sha3HashCb callback)
 {
     Sha3HashNative(data, len, self, callback);
 }