private bool ChangePassword(byte[] Password, int id)
        {
            string loginString = Encoding.Unicode.GetString(ClientsList[id - 1].Login);

            //this.ClientsList[id-1].Password = Password;
            this.ClientsList[id - 1].Password = FileWork.getSHA1(Password);
            /// write to file
            return(FileWork.SaveClientInfo(loginString, Password));
        }
 public bool CheckPassword(byte[] data, int id)
 {
     byte[] Password     = new byte[Const.PASSWORD_SIZE];
     byte[] HashPassword = FileWork.getSHA1(Password);
     for (int i = 0; i < HashPassword.Length; i++)
     {
         if (HashPassword[i] != ClientsList[id - 1].Password[i])
         {
             return(false);
         }
     }
     ClientsList[id - 1].isAuthorised = true;
     return(true);
 }
        public bool SetPassword(byte[] data, int id)
        {
            byte[] DecodeData = this.ClientsList[id - 1].Cipher.decode(data);
            if (DecodeData[Const.CONTROL_NUMBER_POSITION] != Const.CONTROL_NUMBER)
            {
                this.ServerMessage("подпись невалидна", id);
                return(false);
            }
            byte[] newPassword = getData(DecodeData);

            if (this.ClientsList[id - 1].isAuthorised)
            {
                this.ClientsList[id - 1].Password = FileWork.getSHA1(newPassword);
                if (!FileWork.SaveClientInfo(Encoding.Unicode.GetString(this.ClientsList[id - 1].Login),
                                             this.ClientsList[id - 1].Password))
                {
                    this.ServerMessage("не удалось поменять пароль", id);
                    return(false);
                }
                ///////////////////////////////////////////////////////////SaveToFile

                this.ServerMessage("пароль изменен", id);
                return(true);
            }
            else
            {
                if (FileWork.getSHA1(newPassword) == this.ClientsList[id - 1].Password)
                {
                    this.ClientsList[id - 1].isAuthorised = true;
                    ServerMessage("клиент авторизирован", id);
                    BroadcastAboutNewUser(this.ClientsList[id - 1].Id, this.ClientsList[id - 1].Login,
                                          this.ClientsList[id - 1].Cipher.publicKey);
                }
            }

            return(false);
        }