示例#1
0
        private void IniciarSesion()
        {
            string usuario = txtUsuario.Text.Trim();
            string contra  = txtContra.Text.Trim();

            if (usuario == string.Empty || contra == string.Empty)
            {
                MessageBox.Show("Debe ingresar su identificador y su contraseña."
                                , "SysLab", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                var ps = new CTRL.Persistencia();
                ps.IniciarTransaccion();

                MD5.MD5 encrip = new MD5.MD5(contra);
                if (CTRL.Administracion.Usuarios.IniciarSesion(ps.DB, usuario, encrip.FingerPrint))
                {
                    var reg = ps.SelPorLlave <USUARIO>(usuario);
                    this._Sesion      = new Sesion(true, reg.TIPO, usuario, reg.NOMBRES, reg.APELLIDOS);
                    this.DialogResult = DialogResult.OK;
                    this.Dispose();
                }
                else
                {
                    MessageBox.Show("El nombre de usuario no existe o la contraseña es incorrecta."
                                    + Environment.NewLine + "Por favor, intente nuevamente.", "SysLab",
                                    MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                ps.FinalizarTransaccion();
            }
        }
示例#2
0
        public static void Main(string[] args)
        {
            // 0:32ms CreatePaddedBuffer { i = 4, offset = 60, value = 40, sizeMsg = 40 }
            var i       = 4;
            var sizeMsg = 40;
            var ii      = ((8 - i) * 8);

            var value = (byte)(sizeMsg >> ii & 0x00000000000000ff);



            var a = new MD5.MD5();

            //a.FingerPrint
            //a.Value = "the string";
            a.Value = "hello";

            // { FingerPrint = FFFFFFA3FFFFFFF8FFFFFFA1FFFFFFBD }
            // a.FingerPrint = "44D5A3F30F0328E0CF60CD275ED3AAC9"

            //CalculateMD5Value enter { dg_A = 1732584193, dg_B = 4023233417, dg_C = 2562383102, dg_D = 271733878 }
            //CalculateMD5Value exit { dg_A = 3649838548, dg_B = 78774415, dg_C = 2550759657, dg_D = 2118318316 }

            //:16ms CalculateMD5Value enter { dg_A = 1732584193, dg_B = 4023233417, dg_C = 2562383102, dg_D = 271733878 } view-source:36394
            //0:19ms CalculateMD5Value exit { dg_A = 14673034629, dg_B = 17145879128, dg_C = 15685499199, dg_D = 12226463623 } view-source:36394


            // a.FingerPrint = "D41D8CD98F00B204E9800998ECF8427E"
            Console.WriteLine(new { a.FingerPrint });

            RewriteToUltraApplication.AsProgram.Launch(typeof(Application));
        }
示例#3
0
        private void BuildApiSig()
        {
            StringBuilder apiSig = new StringBuilder();

            apiSig.Append("album");
            apiSig.Append(this.album);
            apiSig.Append("api_key");
            apiSig.Append(LastFmConnector.lastFmApiKey);
            apiSig.Append("artist");
            apiSig.Append(this.artist);
            apiSig.Append("duration");
            apiSig.Append(this.duration);
            apiSig.Append("method");
            apiSig.Append(this.method);
            apiSig.Append("sk");
            apiSig.Append(LastFmConnector.lastFmSessionKey);
            apiSig.Append("timestamp");
            apiSig.Append(this.timestamp);
            apiSig.Append("track");
            apiSig.Append(this.track);
            apiSig.Append("trackNumber");
            apiSig.Append(this.trackNumber);
            apiSig.Append(LastFmConnector.lastFmSecret);

            MD5.MD5 md = new MD5.MD5();
            md.Value = apiSig.ToString();
            LastFmConnector.lastFmApiSig = md.FingerPrint.ToLower();
        }
示例#4
0
            public static bool AgregarUsuario(dbDataContext db, string clave, string telefono, string identificador,
                                              string nombres, string correo, string apellidos, string tipo)
            {
                try
                {
                    MD5.MD5 encrip = new MD5.MD5(clave);

                    var reg = new USUARIO
                    {
                        ID_USUARIO   = identificador,
                        NOMBRES      = nombres,
                        APELLIDOS    = apellidos,
                        TELEFONO     = telefono,
                        FECHA_CREADO = DateTime.Now,
                        CORREO       = correo,
                        TIPO         = tipo,
                        CLAVE        = encrip.FingerPrint
                    };

                    db.USUARIOs.InsertOnSubmit(reg);

                    db.SubmitChanges();

                    return(true);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Ha ocurrido un error no controlado al agregar el usuario.\n\n" + ex.Message, "SysLab", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return(false);
                }
            }
示例#5
0
        public static void Main(string[] args)
        {
            // 0:32ms CreatePaddedBuffer { i = 4, offset = 60, value = 40, sizeMsg = 40 } 
            var i = 4;
            var sizeMsg = 40;
            var ii = ((8 - i) * 8);

            var value = (byte)(sizeMsg >> ii & 0x00000000000000ff);



            var a = new MD5.MD5();

            //a.FingerPrint
            //a.Value = "the string";
            a.Value = "hello";

            // { FingerPrint = FFFFFFA3FFFFFFF8FFFFFFA1FFFFFFBD }
            // a.FingerPrint = "44D5A3F30F0328E0CF60CD275ED3AAC9"

            //CalculateMD5Value enter { dg_A = 1732584193, dg_B = 4023233417, dg_C = 2562383102, dg_D = 271733878 }
            //CalculateMD5Value exit { dg_A = 3649838548, dg_B = 78774415, dg_C = 2550759657, dg_D = 2118318316 }

            //:16ms CalculateMD5Value enter { dg_A = 1732584193, dg_B = 4023233417, dg_C = 2562383102, dg_D = 271733878 } view-source:36394
            //0:19ms CalculateMD5Value exit { dg_A = 14673034629, dg_B = 17145879128, dg_C = 15685499199, dg_D = 12226463623 } view-source:36394


            // a.FingerPrint = "D41D8CD98F00B204E9800998ECF8427E"
            Console.WriteLine(new { a.FingerPrint });

            RewriteToUltraApplication.AsProgram.Launch(typeof(Application));
        }
示例#6
0
        protected string EncodePassword(string password)
        {
            var md5 = new MD5.MD5 {
                Value = password
            };

            return(md5.FingerPrint);
        }
        /// <summary>
        /// This is a javascript application.
        /// </summary>
        /// <param name="page">HTML document rendered by the web server which can now be enhanced.</param>
        public Application(IApp page)
        {
            var a = new MD5.MD5();

            //a.FingerPrint
            a.Value = "hello";

            // -- { FingerPrint = D41D8CD98F00B204E9800998ECF8427E }
            // a.FingerPrint = "D41D8CD98F00B204E9800998ECF8427E"
            // { FingerPrint = FFFFFFA3FFFFFFF8FFFFFFA1FFFFFFBD }
            new IHTMLPre { new { a.FingerPrint } }.AttachToDocument();

        }
示例#8
0
        /// <summary>
        /// This is a javascript application.
        /// </summary>
        /// <param name="page">HTML document rendered by the web server which can now be enhanced.</param>
        public Application(IApp page)
        {
            var a = new MD5.MD5();

            //a.FingerPrint
            a.Value = "hello";

            // -- { FingerPrint = D41D8CD98F00B204E9800998ECF8427E }
            // a.FingerPrint = "D41D8CD98F00B204E9800998ECF8427E"
            // { FingerPrint = FFFFFFA3FFFFFFF8FFFFFFA1FFFFFFBD }
            new IHTMLPre {
                new { a.FingerPrint }
            }.AttachToDocument();
        }
        private void BuildApiSig()
        {
            StringBuilder apiSig = new StringBuilder();

            apiSig.Append("api_key");
            apiSig.Append(LastFmConnector.lastFmApiKey);
            apiSig.Append("method");
            apiSig.Append(this.method);
            apiSig.Append("password");
            apiSig.Append(this.password);
            apiSig.Append("username");
            apiSig.Append(LastFmConnector.lastFmUsername);
            apiSig.Append(LastFmConnector.lastFmSecret);

            MD5.MD5 md = new MD5.MD5();
            md.Value = apiSig.ToString();
            LastFmConnector.lastFmApiSig = md.FingerPrint.ToLower();
        }
示例#10
0
        public List <string> EncryptMessage(string message, ElGamalBean el)
        {
            Encryptor encryptor = new Encryptor(el);

            MD5.MD5 hash = new MD5.MD5();
            hash.Value = message;
            List <string> encryptedSequence = new List <string>();

            foreach (char item in hash.Value)
            {
                int messageSymbolAtInt = (int)item;

                StringBuilder aAndB = new StringBuilder();
                aAndB.Append(encryptor.GetA());
                aAndB.Append('|');
                aAndB.Append(encryptor.GetB(new BigInteger(messageSymbolAtInt.ToString())));
                encryptedSequence.Add(aAndB.ToString());
            }

            return(encryptedSequence);
        }
示例#11
0
            public static bool EditarUsuario(dbDataContext db, string identificador, string clave, string telefono,
                                             string nombres, string correo, string apellidos, string tipo)
            {
                try
                {
                    var reg = db.USUARIOs.Where(c => c.ID_USUARIO == identificador).SingleOrDefault();

                    if (reg == null)
                    {
                        MessageBox.Show("El registro a editar no fue encontrado.", "SysLab", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return(false);
                    }
                    else
                    {
                        MD5.MD5 encrip = new MD5.MD5(clave);

                        reg.NOMBRES   = nombres;
                        reg.APELLIDOS = apellidos;
                        reg.TELEFONO  = telefono;
                        reg.TIPO      = tipo;
                        reg.CORREO    = correo;
                        if (clave != string.Empty)
                        {
                            reg.CLAVE = encrip.FingerPrint;
                        }

                        db.SubmitChanges();

                        return(true);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Ha ocurrido un error al editar el usuario.\n\n" + ex.Message, "SysLab", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return(false);
                }
            }
示例#12
0
        private async void tbn_Tap_Login(object sender, System.Windows.Input.GestureEventArgs e)
        {
            if (txt_UserId.Text != "" && txt_Password.ActionButtonCommandParameter.ToString() != "")
            {
                ShowLoadingScreen();
                var uid = txt_UserId.Text;
                MD5.MD5 pw = new MD5.MD5();
                pw.Value = txt_Password.ActionButtonCommandParameter.ToString();
                var pwmd5 = pw.FingerPrint.ToLower();
                var mid = pushChannelURI; //HttpUtility.UrlEncode(pushChannelURI); ;
                var mType = ConstantVariable.mTypeWIN;
                var input = string.Format("{{\"uid\":\"{0}\",\"pw\":\"{1}\",\"mid\":\"{2}\",\"mType\":\"{3}\"}}", uid, pwmd5, mid, mType);

                try
                {
                    //Thử xem có lấy đc dữ liệu ko
                    var output = await GetJsonFromPOSTMethod.GetJsonString(ConstantVariable.tNetDriverLoginAddress, input);
                    var driverLogin = JsonConvert.DeserializeObject<DriverLogin>(output);
                    if (driverLogin != null)
                    {
                        //Kiểm tra các trường hợp trả về
                        switch (driverLogin.status)
                        {
                            case ConstantVariable.RESPONSECODE_SUCCESS: //0000 OK
                                tNetAppSetting["isLogin"] = "******"; //Change login state to Logined
                                NavigationService.Navigate(new Uri("/Pages/DriverCarList.xaml", UriKind.Relative));
                                tNetUserLoginData["UserId"] = uid;
                                tNetUserLoginData["PasswordMd5"] = pwmd5;
                                tNetUserLoginData["UserLoginData"] = driverLogin;
                                tNetUserLoginData["UserLmd"] = driverLogin.lmd;
                                tNetUserLoginData["RawPassword"] = txt_Password.ActionButtonCommandParameter.ToString();
                                tNetUserLoginData["PushChannelURI"] = pushChannelURI;
                                HideLoadingScreen();
                                break;
                            case ConstantVariable.RESPONSECODE_USERNAME_NOT_CORRECT: //Tài khoản không đúng
                                ShowMessageUSERNAME_NOT_CORRECT();
                                HideLoadingScreen();
                                break;
                            case ConstantVariable.RESPONSECODE_PASSWORD_NOT_CORRECT:
                                ShowMessagePASSWORD_NOT_CORRECT();
                                HideLoadingScreen();
                                break;
                            case ConstantVariable.RESPONSECODE_ERR_SYSTEM:
                                ShowMessageERR_SYSTEM();
                                HideLoadingScreen();
                                break;
                            case ConstantVariable.RESPONSECODE_INVALID_PASSWORD:
                                ShowMessageINVALID_PASSWORD();
                                HideLoadingScreen();
                                break;
                            case ConstantVariable.RESPONSECODE_USERNAME_NOT_FOUND:
                                ShowMessageUSERNAME_NOT_FOUND();
                                HideLoadingScreen();
                                break;
                            case ConstantVariable.RESPONSECODE_INVALID_USER_GROUP:
                                ShowMessageINVALID_USER_GROUP();
                                HideLoadingScreen();
                                break;
                            default:
                                MessageBox.Show("(Mã lỗi 3101) " + ConstantVariable.errLoginFailed);
                                HideLoadingScreen();
                                Debug.WriteLine("Có lỗi 265fgt67 ở Driver Login");
                                break;

                        }
                    }
                    else
                    {
                        MessageBox.Show("(Mã lỗi 3102) " + ConstantVariable.errServerError);
                        HideLoadingScreen();
                        Debug.WriteLine("Có lỗi 693fgh10 ở Driver Login");
                    }
                }
                catch (Exception)
                {
                    //Nếu không thì
                    MessageBox.Show("(Mã lỗi 3103) " + ConstantVariable.errConnectingError);
                    HideLoadingScreen();
                    Debug.WriteLine("Có lỗi 78s558 ở Driver Login");
                }

            }
            else
            {
                MessageBox.Show("(Mã lỗi 3104) " + ConstantVariable.errNotEmpty);
                HideLoadingScreen();
                Debug.WriteLine("Có lỗi 68dfghr ở Driver Login");
            }

        }
示例#13
0
        private async void tbn_Tap_Login(object sender, System.Windows.Input.GestureEventArgs e)
        {
            if (txt_UserId.Text != "" && txt_Password.ActionButtonCommandParameter.ToString() != "")
            {
                ShowLoadingScreen();
                var uid = txt_UserId.Text;
                MD5.MD5 pw = new MD5.MD5();
                pw.Value = txt_Password.ActionButtonCommandParameter.ToString();
                var pwmd5 = pw.FingerPrint.ToLower();
                var mid = "";//pushChannelURI;
                var mType = ConstantVariable.mTypeWIN;
                var input = string.Format("{{\"uid\":\"{0}\",\"pw\":\"{1}\",\"mid\":\"{2}\",\"mType\":\"{3}\"}}", uid, pwmd5, mid, mType);
                try
                {
                    //Thử xem có lấy đc JSON về ko, nếu ko thì bắn ra Lối kết nối / lỗi server
                    var output = await GetJsonFromPOSTMethod.GetJsonString(ConstantVariable.tNetRiderLoginAddress, input);
                    riderLogin = new RiderLogin();
                    riderLogin = JsonConvert.DeserializeObject<RiderLogin>(output);
                    if (riderLogin != null)
                    {
                        switch (riderLogin.status)
                        {
                            case ConstantVariable.RESPONSECODE_SUCCESS: //0000 OK
                                tNetAppSetting["isLogin"] = "******";
                                NavigationService.Navigate(new Uri("/Pages/HomePage.xaml", UriKind.Relative));
                                tNetUserLoginData["UserId"] = uid;
                                tNetUserLoginData["PasswordMd5"] = pwmd5;
                                tNetUserLoginData["UserLoginData"] = riderLogin;
                                tNetUserLoginData["RawPassword"] = txt_Password.ActionButtonCommandParameter.ToString();
                                tNetUserLoginData["UserLmd"] = riderLogin.content.lmd; //Cái này là để cập nhật lmd cho việc update thông tin
                                HideLoadingScreen();
                                break;
                            case ConstantVariable.RESPONSECODE_USERNAME_NOT_CORRECT: //Tài khoản không đúng
                                ShowMessageUSERNAME_NOT_CORRECT();
                                HideLoadingScreen();
                                break;
                            case ConstantVariable.RESPONSECODE_PASSWORD_NOT_CORRECT:
                                ShowMessagePASSWORD_NOT_CORRECT();
                                HideLoadingScreen();
                                break;
                            case ConstantVariable.RESPONSECODE_ERR_SYSTEM:
                                ShowMessageERR_SYSTEM();
                                HideLoadingScreen();
                                break;
                            case ConstantVariable.RESPONSECODE_INVALID_PASSWORD:
                                ShowMessageINVALID_PASSWORD();
                                HideLoadingScreen();
                                break;
                            case ConstantVariable.RESPONSECODE_USERNAME_NOT_FOUND:
                                ShowMessageUSERNAME_NOT_FOUND();
                                HideLoadingScreen();
                                break;
                            case ConstantVariable.RESPONSECODE_INVALID_USER_GROUP:
                                ShowMessageINVALID_USER_GROUP();
                                HideLoadingScreen();
                                break;
                            default:
                                MessageBox.Show("(Mã lỗi 1105) " + ConstantVariable.errLoginFailed);
                                HideLoadingScreen();
                                Debug.WriteLine("Có lỗi 265fgt67 ở Rider Login");
                                break;
                        }
                    }
                    else
                    {
                        MessageBox.Show("(Mã lỗi 1102) " + ConstantVariable.errLoginFailed);
                        HideLoadingScreen();
                        Debug.WriteLine("Có lỗi 2356fgg ở Login");
                    }

                }
                catch (Exception)
                {
                    MessageBox.Show("(Mã lỗi 1101) " + ConstantVariable.errConnectingError);
                    HideLoadingScreen();
                    Debug.WriteLine("Có lỗi 25hg567 ở Login");
                }
            }
            else
            {
                MessageBox.Show("(Mã lỗi 1109) " + ConstantVariable.errNotEmpty);
                HideLoadingScreen();
            }
        }
示例#14
0
 public static string ConvertStringToMD5(string inputStr)
 {
     MD5.MD5 md = new MD5.MD5();
     md.Value = inputStr;
     return md.FingerPrint;
 }