breaststroke
Programmer
Hello,
it is the first time I use crypt function.
I just wanted to secure some data but nothing complicated.
I use it this way:
I retrieve a variable, for instance: $variable.
Then I create a salt everytime I want to encrypt some data.
So, I do this:
$newvalue=crypt($variable, $salt);
Then I keep $newvalue and $salt into the database.
I realised there is a problem when trying to decrypt those data (passwords, in this case).
For instance, if I want to check if a password given by an user is already in the database.
What I do is checking if the salt values in the database, when used along with the new password, match any $newvalue in the database.
I have found out that, for instance, if I firstly used the $variable: pepepepe, it will match (its $newvalue) the value of the $newvalue got by using $variable (the new password): pepepepeno.
It matches also other variations.
So, I mean, this method (crypt) doesn´t seem to be reliable to me, it doesn´t seem to create unique values (as I have seen, different $variable values can generate the same $newvalue values).
To summarize (sorry if I didn´t explain myself properly):
For instance:
$variable1="pepepepe";
$variable2="pepepepeno";
$salt="qqwwee111111111";
$newvalue1=($variable1,$salt);
$newvalue2=($variable2,$salt);
It turns out that $newvalue1==$newvalue2;
Could someone, please, tell me what is wrong with crypt (it is supposed to be a method for securing data) and how I could fix it?
Thank you!
enjoy practicing languages at:
it is the first time I use crypt function.
I just wanted to secure some data but nothing complicated.
I use it this way:
I retrieve a variable, for instance: $variable.
Then I create a salt everytime I want to encrypt some data.
So, I do this:
$newvalue=crypt($variable, $salt);
Then I keep $newvalue and $salt into the database.
I realised there is a problem when trying to decrypt those data (passwords, in this case).
For instance, if I want to check if a password given by an user is already in the database.
What I do is checking if the salt values in the database, when used along with the new password, match any $newvalue in the database.
I have found out that, for instance, if I firstly used the $variable: pepepepe, it will match (its $newvalue) the value of the $newvalue got by using $variable (the new password): pepepepeno.
It matches also other variations.
So, I mean, this method (crypt) doesn´t seem to be reliable to me, it doesn´t seem to create unique values (as I have seen, different $variable values can generate the same $newvalue values).
To summarize (sorry if I didn´t explain myself properly):
For instance:
$variable1="pepepepe";
$variable2="pepepepeno";
$salt="qqwwee111111111";
$newvalue1=($variable1,$salt);
$newvalue2=($variable2,$salt);
It turns out that $newvalue1==$newvalue2;
Could someone, please, tell me what is wrong with crypt (it is supposed to be a method for securing data) and how I could fix it?
Thank you!
enjoy practicing languages at: