Exemple #1
0
 function insertUser($userArray)
 {
     $currTimestamp = time();
     $crypt = new Crypt();
     $salt = $crypt->generateSalt();
     $encPass = $crypt->crypt($userArray["password"], $salt);
     $this->db->exec("INSERT INTO users (name,surname,email,salt,password,active,is_admin,created_on) VALUES (:name,:surname,:email,:salt,:password,:active,:is_admin,:created_on)", array(':name' => $userArray["name"], ':surname' => $userArray["surname"], ':email' => $userArray["email"], ':salt' => $salt, ':password' => $encPass, ':active' => 1, ':is_admin' => 1, ':created_on' => time()));
 }
Exemple #2
0
<?php

include_once 'Crypt.php';
$key = 'super_secret_key';
$text = 'Hello world';
$c1 = new Crypt($key);
$encrypted_text = $c1->crypt($text);
echo "encrypted text: {$encrypted_text}\n";
$c2 = new Crypt($key);
$plain_text = $c2->decrypt($encrypted_text);
echo "plain text: {$plain_text}\n";