Beispiel #1
0
        unsafe public string MessageReceiving(string accountName, string protocol, string sender, string message)
        {
            IntPtr contextp;
            IntPtr newmessagep;
            int    r = OtrApi.otrl_message_receiving(
                Handle,
                ref ops,
                GCHandle.ToIntPtr(GCHandle), // opdata
                accountName,
                protocol,
                sender,
                message,
                out newmessagep,
                IntPtr.Zero,
                out contextp,
                null,
                IntPtr.Zero
                );

            //Console.WriteLine(r);
            //Console.WriteLine(GCryptApi.MessageFromErrorCode(r));

            var decryptedMessage = Marshal.PtrToStringAnsi(newmessagep);

            OtrApi.otrl_message_free(newmessagep);
            return(decryptedMessage);
        }
Beispiel #2
0
        unsafe public string MessageSending(string accountName, string protocol, string recipient, string message)
        {
            IntPtr contextp;
            IntPtr messagep; // this will contain the encrypted message
            int    r = OtrApi.otrl_message_sending(
                Handle,
                ref ops,
                GCHandle.ToIntPtr(GCHandle), // opdata
                accountName,
                protocol,
                recipient,
                InstanceTag.Best,
                message,
                IntPtr.Zero, //otrltlv
                out messagep,
                OtrlFragmentPolicy.Skip,
                //ref NULL,
                out contextp,
                null,
                IntPtr.Zero
                );

            //Console.WriteLine(GCryptApi.MessageFromErrorCode(r));

            string encryptedMessage = Marshal.PtrToStringAnsi(messagep);

            OtrApi.otrl_message_free(messagep);
            return(encryptedMessage);
        }