Advertisement
Guest User

Untitled

a guest
Apr 30th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. <?php
  2. require_once 'core/init.php';
  3.  
  4. if(Input::exists()){
  5.  
  6. $user = new User();
  7. $salt = Hash::salt(32);
  8.  
  9. try{
  10.  
  11. $user->create(array(
  12. 'uname' => Input::get('uname'),
  13. 'mail' => Input::get('mail'),
  14. 'pass' => Hash::make(Input::get('pass'), $salt),
  15. 'salt' => $salt
  16.  
  17. ));
  18.  
  19. Session::flash('home', 'You have registered successfully now you can log in !');
  20. Redirect::to('index.html');
  21.  
  22. }catch(Exception $e){
  23. die($e->getMessage());
  24. }
  25.  
  26.  
  27. }
  28.  
  29. ?>
  30.  
  31. <?php
  32. class Hash{
  33. public static function make($string, $salt = ''){
  34. return hash('sha256', $string . $salt);
  35. }
  36.  
  37. public static function salt($length){
  38. return mcrypt_create_iv($length);
  39.  
  40. }
  41.  
  42. public static function unique(){
  43. return self::make(uniqid());
  44.  
  45. }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement