public void CambiarContraseña(int idusuario, String password)
        {
            Usuario user = this.BuscarUsuario(idusuario);

            String salt = CypherService.GetSalt();

            user.Salt     = salt;
            user.Password = CypherService.CifrarContenido(password, salt);

            this.context.SaveChanges();
        }
示例#2
0
        public void InsertarUsuario(int idusuario, string nombre, string username, string password)
        {
            Usuario user = new Usuario();

            user.IdUsuario = idusuario;
            user.Nombre    = nombre;
            user.UserName  = username;
            string salt = CypherService.GetSalt();

            user.Salt = salt;
            byte[] respuesta = CypherService.CifrarContenido(password, salt);
            user.Password = respuesta;
            this.context.Usuarios.Add(user);
            this.context.SaveChanges();
        }
        public void InsertUser(string nombre, string username, string password)
        {
            Usuario user = new Usuario();

            //user.idUser = GetMaxIdUser();
            //en el 1º registro estamos obligados a meterle el
            //valor a cañon para que no nos falle el codigo en
            //el metodo incremental
            user.idUser = 1;
            user.name   = nombre;
            user.user   = username;
            String salt = CypherService.GetSalt();

            user.salt = salt;
            byte[] respuesta = CypherService.CypherHashefficent(password, salt);
            user.pswd = respuesta;
            this.context.Usuarios.Add(user);
            this.context.SaveChanges();
        }
        public void InsertarUsuario(String username, String nombre, String correo, String password, String direccion, String telefono)
        {
            if (!this.UserNameExists(username))
            {
                Usuario user = new Usuario();
                user.IdUsuario = this.GetMaxId(Tablas.Usuarios);
                user.UserName  = username;
                user.Nombre    = nombre;
                user.Correo    = correo;
                user.Direccion = direccion;
                user.Telefono  = telefono;

                String salt = CypherService.GetSalt();
                user.Salt     = salt;
                user.Password = CypherService.CifrarContenido(password, salt);

                user.Validado = true;
                user.Rol      = 0;

                this.context.Usuarios.Add(user);
                this.context.SaveChanges();
            }
        }
示例#5
0
        public void Insert(String nombre, String username, String password)
        {
            Usuario user = new Usuario();

            user.IdUsuario = this.GetMaxIdUsuario();
            user.Nombre    = nombre;
            user.UserName  = username;
            String salt = CypherService.GetSalt();

            user.Salt = salt;
            byte[] respuesta = CypherService.CifrarContenido(password, salt);
            user.Password = respuesta;
            this.context.Usuarios.Add(user);
            this.context.SaveChanges();
            //CON PROCEDIMIENTO
            //String sql = "insertarusuario @username, @pass, @nombre, @salt";
            //SqlParameter parusername = new SqlParameter("@username", username);
            //SqlParameter parnombre = new SqlParameter("@nombre", nombre);
            //String salt = CypherService.GetSalt();
            //SqlParameter parsalt = new SqlParameter("@salt", salt);
            //byte[] passcifrada = CypherService.CifrarContenido(password, salt);
            //SqlParameter parpass = new SqlParameter("@pass", passcifrada);
            //this.context.Database.ExecuteSqlRaw(sql, parusername, parpass, parnombre, parsalt);
        }