added a security file for hashing and the likes, as well as a setup file to keep track of table creations until I actually set that up

This commit is contained in:
hayden 2019-06-26 00:16:52 -05:00
parent 0fc08647c0
commit 8d3a822965
2 changed files with 19 additions and 0 deletions

10
core/security.php Normal file
View File

@ -0,0 +1,10 @@
<?php
function hash_string($input, $rounds = 5) {
$salt = "";
$salt_chars = array_merge(range('A','Z'), range('a','z'), range(0,9));
for($i=0; $i < 22; $i++) {
$salt .= $salt_chars[array_rand($salt_chars)];
}
return crypt($input, sprintf('$2y$%02d$', $rounds) . $salt);
}
?>

9
core/setup.php Normal file
View File

@ -0,0 +1,9 @@
<?php
$USERS_SQL = "CREATE TABLE user ( id MEDIUMINT NOT NULL AUTO_INCREMENT,
username VARCHAR(32) NOT NULL,
password VARCHAR(64) NOT NULL,
admin BOOL NOT NULL,
registered DATE NOT NULL,
last_login DATE,
PRIMARY KEY (id))";
?>