In the case of very sensitive data if the original representation is not necessary using a hash is a good solution. The classic example is the storage of passwords in the database, after having passed the MD5. The following is an example that explains the same :
PHP Code:
<?php
$query = sprintf("INSERT INTO users(name,pwd) VALUES('%s','%s');",
pg_escape_string($username), md5($password));
$result = pg_query($connection, $query);
$query = sprintf("SELECT 1 FROM users WHERE name='%s' AND pwd='%s';",
pg_escape_string($username), md5($password));
$result = pg_query($connection, $query);
if (pg_num_rows($result) > 0) {
echo 'Welcome, $username!';
} else {
echo 'Authentication failed for $username.';
}
?>
Bookmarks