public function testCreatingKeys() { // Check to see if PGP Creation is working $result = \classes\Encryption::createPGPKey('test', 'test'); $this->assertTrue($result); // Verify the key was written. $user = \classes\User::getUserByUsername('test'); $this->assertNotNull($user->getPublickey()); $this->assertNotNull($user->getPrivatekey()); // Verify tmp files were cleaned up. $this->assertFalse(file_exists('/tmp/test')); $this->assertFalse(file_exists('/tmp/test.pub')); $this->assertFalse(file_exists('/tmp/test.sec')); }
private function register($username, $password, $password2) { $userCheck = new \classes\ajax\Registration(array('checkUsername' => $username)); if ($userCheck->getReturn()['checkUsername'] !== 1) { $this->variables['errors']['registration'] = "Invalid Username."; return false; } if ($password !== $password2) { $this->variables['errors']['registration'] = "Passwords do not match."; return; } $register = $this->db->prepare("INSERT INTO users (username, password)\n\t\t\t VALUES (:username, :password)"); $register->execute(array(':username' => $username, ':password' => hash('sha512', md5($username) . $password))); \classes\Encryption::createPGPKey($username, hash('sha512', hash('sha256', $password . md5($username)) . $password)); $this->checkLogin($username, $password); }