コード例 #1
0
ファイル: FTxBase.cs プロジェクト: kangkangwang/Server
        /// <summary>
        ///     数据第二层分配中心;把数据归类
        /// </summary>
        /// <param name="stateOne"></param>
        /// <param name="statecode"></param>
        internal void codeManage(StateBase stateOne, StateCode statecode)
        {
            if (statecode == null || stateOne == null)
            {
                return;
            }
            StateCode stateCode = null;

            switch (statecode.State)
            {
            case PasswordCode._commonCode:     //普通数据信息;抛给普通Code去处理
                stateCode = EncryptionDecrypt.deciphering(statecode.DateByte, stateOne);
                CommonCodeManage(stateOne, stateCode);
                break;

            case PasswordCode._bigDateCode:     //抛给分包Code去处理
                stateCode = EncryptionDecryptSeparateDate.FileDecrypt(statecode.DateByte, stateOne);
                CommonCodeManage(stateOne, stateCode);
                break;

            case PasswordCode._fileCode:     //抛给文件处理器去处理;如果返回null就不用发送了
                byte[] haveDate = FileStart.ReceiveDateTO(statecode.DateByte, stateOne);
                if (haveDate != null)
                {
                    Send(stateOne, haveDate);
                }
                break;
            }
        }
コード例 #2
0
        /// <summary>
        /// 数据第二层分配中心;把数据归类
        /// </summary>
        /// <param name="stateOne">连接属性</param>
        /// <param name="statecode">收到的数据</param>
        internal void codeManage(TransmitData stateOne, DataModel statecode)
        {
            if (statecode == null || stateOne == null)
            {
                return;
            }
            DataModel stateCode = null;

            switch (statecode.State)
            {
            case CipherCode._commonCode:    //普通数据信息;抛给普通Code去处理
                stateCode = EncryptionDecrypt.deciphering(statecode.DateByte, stateOne);
                CommonCodeManage(stateOne, stateCode);
                break;

            case CipherCode._bigDateCode:                                                 //抛给分包Code去处理
                stateCode = EncDecSeparateDate.FileDecrypt(statecode.DateByte, stateOne); //返回一个带回复数据的模型
                CommonCodeManage(stateOne, stateCode);                                    //发送出去
                break;

            case CipherCode._fileCode:    //抛给文件处理器去处理;如果返回null就不用发送了
                byte[] haveDate = FileStart.ReceiveDateTO(statecode.DateByte, stateOne);
                if (haveDate != null)
                {
                    Send(stateOne, haveDate);
                }
                break;
            }
        }
コード例 #3
0
ファイル: ucUserScreen.cs プロジェクト: spefanis/CRM_Sample
        //This stops the recording functionality and does the speack to text convertion
        //INPUT:
        //OUTPUT:
        private void stopRecording()
        {
            //Stop the timer
            timerClock.Stop();


            //stop recordinmg from the microphone
            audioCapture a = new audioCapture();

            a.OnRecordingStopped(null, null);

            //Enable/Disable the buttons as required
            btnStartCommand.Enabled = true;
            btnStopCommand.Enabled  = false;

            //Show the length of the sample for the user to see
            double sampleLength = (audioCapture.recordingEnded - audioCapture.recordingStarted).TotalMilliseconds * 0.001;

            lblRecordingLength.Text = Math.Round(sampleLength, 2).ToString();
            //If the sample lenght is greater than 2.5 seconds

            if (doSpeechTextValidation())
            {
                string sitekey       = "";
                string username      = "";
                string website       = "";
                string encryptedPass = "";
                bool   keyFound      = false;


                //If we find a valid login, then find the matching website and login credientials
                foreach (DataGridViewRow dr in dgvUserAccounts.Rows)
                {
                    sitekey       = dr.Cells["SiteKey"].Value.ToString();
                    username      = dr.Cells["username"].Value.ToString();
                    website       = dr.Cells["website"].Value.ToString();
                    encryptedPass = dr.Cells["password"].Value.ToString();
                    if (txtTextRecognises.Text.ToLower().Contains(sitekey.ToLower()))
                    {
                        keyFound = true;
                        break;
                    }
                }
                if (keyFound)
                {
                    EncryptionDecrypt ende = new EncryptionDecrypt();
                    frmWebLoader      f    = new frmWebLoader(website, username, ende.Decrypt(encryptedPass));
                    f.ShowDialog();
                }
                else
                {
                    MessageBox.Show("Unable to find matching logon details for the command spoken");
                }
            }
            else
            {
                MessageBox.Show("Do Nothing here");
            }
        }
コード例 #4
0
ファイル: FTxBase.cs プロジェクト: kangkangwang/Server
        /// <summary>
        ///     服务器向客户端发送文本数据
        /// </summary>
        /// <param name="stateOne">StateBase</param>
        /// <param name="data">未加密的数据</param>
        internal void sendMessage(StateBase stateOne, string data)
        {
            if (stateOne == null)
            {
                return;
            }
            var stateCode = new StateCode(PasswordCode._textCode, data);

            byte[] sendDate = EncryptionDecrypt.encryption(stateCode, stateOne);
            stateOne.SendDate = sendDate;
            Send(stateOne, sendDate);
        }
コード例 #5
0
        /// <summary>
        /// 服务器向客户端发送图片数据
        /// </summary>
        /// <param name="stateOne">StateBase</param>
        /// <param name="data">未加密的数据</param>
        internal void sendMessage(StateBase stateOne, byte[] data)
        {
            if (stateOne == null)
            {
                return;
            }
            StateCode stateCode = new StateCode(PasswordCode._photographCode, data);

            byte[] sendDate = EncryptionDecrypt.encryption(stateCode, stateOne);
            stateOne.SendDate = sendDate;
            Send(stateOne, sendDate);
        }
コード例 #6
0
        /// <summary>
        /// 服务器向客户端发送图片数据
        /// </summary>
        /// <param name="stateOne">StateBase</param>
        /// <param name="data">未加密的数据</param>
        internal void sendMessage(TransmitData stateOne, byte[] data)
        {
            if (stateOne == null)
            {
                return;
            }
            DataModel stateCode = new DataModel(CipherCode._photographCode, data);

            //取得要发数据
            byte[] sendDate = EncryptionDecrypt.encryption(stateCode, stateOne);
            stateOne.SendDate = sendDate;
            Send(stateOne, sendDate);
        }
コード例 #7
0
        /// <summary>
        /// 发送文本数据
        /// </summary>
        /// <param name="stateOne">StateBase</param>
        /// <param name="data">未加密的数据</param>
        internal void sendMessage(TransmitData stateOne, string data)
        {
            if (stateOne == null)
            {
                return;
            }
            //建立一个数据
            DataModel stateCode = new DataModel(CipherCode._textCode, data);

            //对一个数据进行加密-这里应该是把数据装入快速盒子
            byte[] sendDate = EncryptionDecrypt.encryption(stateCode, stateOne);
            //放入传输的快递盒子
            stateOne.SendDate = sendDate;
            //发送出去()//在这里发送时再进行粘包处理 前面为粘包代码4位+sendDate包长度4位+sendDate
            Send(stateOne, sendDate);
        }
コード例 #8
0
 private void frmAddLogin_Load(object sender, EventArgs e)
 {
     //If it's a new login, change the text so it looks better
     if (public_isNew == true)
     {
         btnAddLogin.Text = "Add";
     }
     else
     {
         //Load the details for the Logon from the database
         Database         db     = new Database();
         List <UserLogin> logins = db.getSpecificLogin(public_AccountID);
         if (logins.Count >= 1)
         {
             txtSiteKey.Text  = logins[0].SiteKey;
             txtUserName.Text = logins[0].username;
             EncryptionDecrypt ende = new EncryptionDecrypt();
             txtPassword.Text = ende.Decrypt(logins[0].password);
             txtWebsite.Text  = logins[0].website;
         }
         this.Text        = "Edit Login";
         btnAddLogin.Text = "Update";
     }
 }
コード例 #9
0
        private void btnDecrypt_Click(object sender, EventArgs e)
        {
            EncryptionDecrypt decrypt = new EncryptionDecrypt();

            txtDestination.Text = decrypt.Decrypt(txtSource.Text);
        }
コード例 #10
0
        private void btnEncrypt_Click(object sender, EventArgs e)
        {
            EncryptionDecrypt encrypt = new EncryptionDecrypt();

            txtDestination.Text = encrypt.EncryptString(txtSource.Text);
        }