Exemplo n.º 1
0
        private static void SendMsgPart(Socket s, string msgPart)
        {
            msgPart = RijndaelSimple.Encrypt(msgPart,
                                             passPhrase,
                                             saltValue,
                                             hashAlgorithm,
                                             passwordIterations,
                                             initVector,
                                             keySize);


            byte[] _msgPart = new byte[msgPart.Length];
            _msgPart = Convert.FromBase64String(msgPart);
            //_msgPart = Encoding.ASCII.GetBytes(msgPart);

            string msgLen = "" + _msgPart.Length;

            msgLen = RijndaelSimple.Encrypt(msgLen,
                                            passPhrase,
                                            saltValue,
                                            hashAlgorithm,
                                            passwordIterations,
                                            initVector,
                                            keySize);
            //MessageBox.Show(msgLen);

            byte[] _msgLen = new byte[1024];
            _msgLen = Convert.FromBase64String(msgLen);
            s.Send(_msgLen, 0, _msgLen.Length, SocketFlags.None);
            //MessageBox.Show("rbytes = " + _msgPart.Length + " length = " + msgPart.Length);
            // Receive an ack
            if (Check_Response(s, SMTPResponse.MSGLEN_SUCCESS))
            {
                //MessageBox.Show("length acked");
            }
            //   MessageBox.Show("length acked");


            s.Send(_msgPart, 0, _msgPart.Length, SocketFlags.None);

            // Receive an ack
            if (Check_Response(s, SMTPResponse.MSGLEN_SUCCESS))
            {
                //MessageBox.Show("msg part acked");
            }
        }
Exemplo n.º 2
0
        private static void Senddata(Socket s, string msg, bool isMsgBody)
        {
            byte[] _msg = new byte[max_length];


            msg = RijndaelSimple.Encrypt(msg,
                                         passPhrase,
                                         saltValue,
                                         hashAlgorithm,
                                         passwordIterations,
                                         initVector,
                                         keySize);


            _msg = Convert.FromBase64String(msg);

            if (isMsgBody)
            {// send the length
                string msgLen = "" + _msg.Length;
                msgLen = RijndaelSimple.Encrypt(msgLen,
                                                passPhrase,
                                                saltValue,
                                                hashAlgorithm,
                                                passwordIterations,
                                                initVector,
                                                keySize);
                //MessageBox.Show(msgLen);

                byte[] _msgLen = new byte[1024];
                _msgLen = Convert.FromBase64String(msgLen);
                s.Send(_msgLen, 0, _msgLen.Length, SocketFlags.None);
                //MessageBox.Show("rbytes = " + _msg.Length + " length = " + msg.Length);
                // Receive an ack
                if (Check_Response(s, SMTPResponse.MSGLEN_SUCCESS))
                {
                    ;
                }
                // MessageBox.Show("length acked");
            }
            s.Send(_msg, 0, _msg.Length, SocketFlags.None);
        }