>PHP: Modelo de Almacenamiento Encriptado - Manual

MANUAL DE PHP

(y algo mas)windsurf pozo izquierdo
Google
search for in the  
ELMARRAJO.COM mysql bulma desarrollo web linux fedora html ayuda

windsurf mercedes camper

Modelo de Almacenamiento Encriptado

SSL/SSH protege los datos que viajan desde el cliente al servidor, SSL/SSH no protege los datos persistentes almacenados en la base de datos. SSL es un protocolo sobre-el-cable.

Una vez el atacante adquiere acceso directo a su base de datos (evitando el paso por el servidor web), los datos críticos almacenados pueden estar expuestos o malutilizados, a menos que la información esté protegida en la base de datos misma. La encriptación de datos es una buena forma de mitigar esta amenaza, pero muy pocas bases de datos ofrecen este tipo de mecanismo de encriptación de datos.

La forma más sencilla de evitar este problema es crear primero su propio paquete de encriptación, y luego utilizarlo desde sus scripts de PHP. PHP puede ayudarle en este sentido con varias extensiones, como Mcrypt y Mhash, las cuales cubren una amplia variedad de algoritmos de encriptación. El script encripta los datos antes de insertarlos en la base de datos, y los decripta cuando los recupera. Vea las referencias para consultar más ejemplos de cómo opera la encriptación.

En el caso de datos realmente escondidos, si su representación original no se necesita (es decir, no debe ser desplegada), los resúmenes criptográficos pueden llegar a considerarse también. El ejemplo clásico de gestión de resúmenes criptográficos es el almacenamiento de secuencias MD5 de una contraseña en una base de datos, en lugar de la contraseña misma. Vea también crypt() y md5().

Ejemplo 27-1. Uso de un campo de contraseñas encriptado

<?php

// almacenamiento de resumen criptografico de la contrasenya
$consulta  = sprintf("INSERT INTO usuarios(nombre,contr) VALUES('%s','%s');",
                    
addslashes($nombre_usuario), md5($contrasenya));
$resultado = pg_query($conexion, $consulta);


// consulta de verificacion de la contrasenya enviada
$consulta  = sprintf("SELECT 1 FROM usuarios WHERE nombre='%s' AND contr='%s';",
                    
addslashes($nombre_usuario), md5($contrasenya));
$resultado = pg_query($conexion, $consulta);

if (
pg_num_rows($resultado) > 0) {
   echo
'&iexcl;Bienvenido, $nombre_usuario!';
}
else {
   echo
'No pudo autenticarse a $nombre_usuario.';
}

?>


add a note add a note User Contributed Notes
Modelo de Almacenamiento Encriptado
roysimkes at hotmail dot com
17-Aug-2006 05:10
But the thing in double hashing is to increase the time that they can crack your password! A passwod that takes a year to break is quite secure(!)
And even if they learn somehow that you are double hashing your passwords, how will they learn which one you are using first! Instead of using md5() twice try using sha1(md5()) or vice versa. An the breaker should check more things. For only one password he has to check at least 4 different types (md5 only, sha1 only, md5(sha1) and sha1(md5) ) it will take quite a time to break it! (Yeah if he can see your source files it doesn't mean anything. But if they can see that files, you are already dead in the water)
And also put a salt variable in it! If that's random salt, it will take a very long time to crack the password. The best security is to use a hybrid solution. If you add salt to your passwords they have to use your app to crack the code. And if you add some more features like after 3 times password failure add a secret question and a secret answer, a visual confirmation code! Things are getting complicated for the automated script!
Well yes if you want to protect something, do not publish them in the internet. With enough dedication, time and resources every password can be cracked. But if the time is more then years, who will waste time on it? Or the password to be cracked worth that time?
dan[ddot) crowley [att]gmail {dott]com
13-Jul-2006 01:31
A note to the people who think that hashing a password multiple times makes it uncrackable:

It doesn't.

If you're using a standard hash cracker or rainbow tables, sure. But if you've got the smarts to design your own hash cracker, you can just double-hash every string where it would normally be hashed once, and then at best your hashes take twice as long to crack.
Fairydave at the location of dodo.com.au
11-Feb-2006 06:58
I think the best way to have a salt is not to randomly generate one or store a fixed one. Often more than just a password is saved, so use the extra data. Use things like the username, signup date, user ID, anything which is saved in the same table. That way you save on space used by not storing the salt for each user.

Although your method can always be broken if the hacker gets access to your database AND your file, you can make it more difficult. Use different user data depending on random things, the code doesn't need to make sense, just produce the same result each time. For example:

if ((asc(username character 5) > asc(username character 2))
{
   if (month the account created > 6)
     salt = ddmmyyyy of account created date
   else
     salt = yyyyddmm of account created date
}
else
{
   if (day of account created > 15)
     salt = user id * asc(username character 3)
   else
     salt = user id + asc(username character 1) + asc(username character 4)
}

This wont prevent them from reading passwords when they have both database and file access, but it will confuse them and slow them up without much more processing power required to create a random salt
3M
05-Oct-2005 08:46
Be smart and simple!

1. Hash a password once on twice! It's sufficient to use SHA-1 twice! (read no.3)
2. Limit the number of log-in trys per ip! This will be a hard hit for online brute force crackers!
3. The comments below that suggest using a SALT whit MD5 ar good as long as the length of the resulting string (password + SALT) is bigger then the output of the hashing algorithm. For example: SHA-1 has an output of 160 bits or 20 ASCII chars. If the password set has 8 chars then the salt would have to be of 12 chars or longer... the longer the better!
The idea here is that by trying to brute force a hash (second) that was computed from another hash (first) from a large string would result in many collisions that will make it impossible to distinguish between them and the first hash of the password!
4. If possible use HMAC for added security! This will prevent sending the same generated hash from a paswrod in the tcp/udp packets... each time the pasword field in tha data packets will contain a different hash (HMAC'ed) but on server side will be decoded to the real hash. For this you will need to design a solution for sending the password needed for HMAC!
blodo at poczta dot fm
07-Jul-2005 02:05
You could always double hash the password, which might just be the easiest way to prevent a hash table crack which typically can only crack hashes that store about 8 characters in length (from what i know). For an additional amount of security you can always append a random salt, although you will need to store the salt to succesfully recover the password for checking. The code could look like this:
<?php

function createSalt ($charno = 5) {

  for (
$i = 0; $i < $charno; $i++;) {
  
  
$num = rand(48, 122); //This is roughly the ascii readable character range
  
$salt .= chr($num); //Convert the number to a real character
      
 
}
  
  return
$salt;
  
}

$randomsalt = createSalt();
$hash = md5(md5($string_to_hash.$randomsalt));

/* Now append this to your database, but remember to store the salt somewhere too, or else you wont be able to check the password later on */

?>

Easy as pie. Hope this helps.
Chris Ladd
05-Jun-2005 11:41
Using a hard coded salt will only prevent a dictionary attack on the raw database and only if the attacker hasn't gained access to the file the salt is stored in. The attacker could still use the php login site to run a dictionary attack, since the php would be adding the hard coded salt to the password, md5ing it, and checking if it matches. The only real way to prevent a dictionary attack is to not allow weak passwords. There is no shortcuts in real security.
oguh at gmx dot net
11-May-2005 11:06
Better use a random value for the salt and store it seperate in the database for every user.

So it is not possible to see if some users have the same password.
Jim Plush - jiminoc at gmail dot com
17-Mar-2005 01:45
Another handy trick is to use MD5 with a "salt". Which basically  means appending another static string to your $password variable to help prevent against dictionary attacks.

Example:
config.php - KEEP THIS OUTSIDE THE WEBROOT
define("PHP_SALT", "iLov3pHp5");
----------------------------------------------

and when you add your database query you would do:
// storing password hash
$query  = sprintf("INSERT INTO users(name,pwd) VALUES('%s','%s');",
           addslashes($username), md5($password.PHP_SALT));

This way if a user's password is "DOG" it can't be guessed easily because their password gets saved to the DB as the MD5 version of "DOGiLov3pHp5". Last time I checked, that wasn't in the dictionary :)

Citas célebres

El verdadero misterio del mundo es lo visible, no lo invisible.

Oscar Wilde
Escritor irlandés
(1854-1900)
Citas en tu mail
©Contenidos Gratis

Ilusiones Opticas
ilusion_optica_051.jpg
Contenidos Web

Chiste de... Transportes
Tranquilidad

- ¡Oye Manolo, que llevas una rueda del camion pinchada!

- ¡Bah! pero es solo por la parte de abajo.
Chistes en tu mail
©ContenidosGratis

Humor Gráfico
humor_grafico_040.jpg
Contenidos Web

Inicio | Acción | Estrategia | Palabras | Puzzles | Solitarios | Foro Trucos
Cake ManiaCake Mania
Jugadores: 6835
Categoría del juego: Acción
Objetivo del juego: Ayuda a Jill a recuperar la pastelería de su abuela llevando su propia pastelería; consigue clientes y gana dinero.
Rainbow WebRainbow Web
Jugadores: 2199
Categoría del juego: Puzzles
Objetivo del juego: Rompe un pegajoso hechizo y salva un reino de fantasía en Rainbow Web. Tendrás toneladas de diversión mientras juegas a este mágico desafío para la mente.
Mahjongg FortunaMahjongg Fortuna
Jugadores: 12462
Categoría del juego: Solitarios
Objetivo del juego: Velocidad y habilidad mental son las armas más importantes en esta versión de un antiguo juego asiático. Despeja el tablero lo antes posible haciendo clic en las fichas iguales y gánate la fama eterna de la puntuación más alta.
Chainz 2Chainz 2
Jugadores: 6955
Categoría del juego: Puzzles
Objetivo del juego: Entra en el mundo de las combinaciones con Chainz 2: Relinked, emocionante secuela del exitazo del año pasado, Chainz. Gira eslabones y crea combinaciones de 3 ó más.
DeliciousDelicious
Jugadores: 4405
Categoría del juego: Acción
Objetivo del juego: ¿Eres un as de la multitarea? ¿Quieres que tus clientes estén contentos? ¡Pues Delicious es tu juego! Sacia el apetito de los clientes y tenlos contentos; ¡no te arriesgues!
BookwormBookworm
Jugadores: 4568
Categoría del juego: Palabras
Objetivo del juego: Junta las letras para formar palabras. ¡Las palabras más largas valen más puntos!
ZumaZuma
Jugadores: 4976
Categoría del juego: Acción
Objetivo del juego: Controla el ídolo de la rana de piedra de los antiguos Zuma en este intrigante enigma de acción. ¡Dispara bolas para formar conjuntos de tres, pero si dejas que lleguen a la calavera dorada morirás!
Jewel of AtlantisJewel of Atlantis
Jugadores: 3798
Categoría del juego: Puzzles
Objetivo del juego: Descubre la ciudad hundida de la Atlántida y busca valiosos tesoros. Viaja más allá de las profundidades del mar y vive trepidantes aventuras en Jewel of Atlantis.
Jewel QuestJewel Quest
Jugadores: 3727
Categoría del juego: Puzzles
Objetivo del juego: Convierte la arena de la antigua selva en oro tan rápido como puedas juntando grupos de 3 elementos. ¡Los grupos más grandes valen más puntos!
Bejeweled 2Bejeweled 2
Jugadores: 3659
Categoría del juego: Puzzles
Objetivo del juego: Con cuatro modos de juego únicos y fascinantes, nuevas piezas de juego explosivas e imponentes fondos planetarios, Bejeweled 2 es mucho más adictivo que nunca.
Contenidos gratis en tu webSiguiente >>

Fotos divertidas
fotos_increibles_0407.jpg
Contenidos Web
microrobots avion deportes riesgo recetas cocina canaria juegos online gratis moto motociclismo horoscopos naranjas valencianas surf canarias montañismo ciudades turismo postales gratis library Horoscopos Diarios Windsurf Canarias
fregadero microondas placa electrica bañopreparar camper pantalla plananevera compresor electricacamper fiat ducato camper baño quimicomampara enrollable bañocamper aire climatizadofurgoneta surf windsurffurgoneta surf windsurftelevisor furgonetas camperfurgonetas camper cama

Sudoku del día
Nivel de dificultad: Fácil



Cómo jugar:
El juego consiste en colocar los números del 1 al nueve de tal forma que no se repita el mismo número en la columna, fila y caja (bloques 3x3 enmarcados).

©Contenidos Gratis | Sudoku en tu mail

Warning: array_rand(): First argument has to be an array in /var/www/html/contenidos/efemerides.php on line 14
Sucedió el...

31 de agosto de

Efemérides en tu mail
©Contenidos Gratis
windsurf canarias youtube porno canarias baleares valencia madrid