コード例 #1
0
<?php

// Display any php errors (for development purposes)
error_reporting(E_ALL);
ini_set('display_errors', '1');
session_start();
require_once __DIR__ . '/../config.php';
// get code query parameter from POST data
$opts = array('http' => array('method' => 'POST'));
$context = stream_context_create($opts);
$url = $_SESSION['canvasURL'] . '/login/oauth2/token?client_id=' . $client_id . '&client_secret=' . $clientSecret . '&code=' . $_GET['code'];
$userTokenJSON = file_get_contents($url, false, $context, -1, 40000);
//ASK CANVAS,	USING DEVELOPER TOKEN, TO RETURN STUDENT TOKEN
$userToken = json_decode($userTokenJSON);
//encrypt token
$cryptastic = new cryptastic();
$key = $cryptastic->pbkdf2($pass, $salt, 1000, 32);
$encrypted_token = $cryptastic->encrypt($userToken->access_token, $key);
//store encrypted token in the database
$userID = $_SESSION['userID'];
DB::insert('tokens', array('canvas_user_id' => $userID, 'encrypted_token' => $encrypted_token, 'domain' => $_SESSION['apiDomain']));
$_SESSION['allowed'] = true;
/*  redirect to main tool page */
header('Location: ' . $_SESSION["template_wizard_url"] . '/index.php');
コード例 #2
0
ファイル: kickstart.api2.php プロジェクト: dapepe/tymio
 /**
  * Validates a Cookie Token
  *
  * @param string $strUsername
  * @param int $intDay The number of days the cookie should be valid
  * @param string $strSalt Token salt
  */
 public function createCookieToken($strUsername, $intDays = 14, $strSalt = false)
 {
     return cryptastic::encrypt(array('username' => $strUsername, 'expiration' => time() + 8600 * $intDays), $strSalt ? $strSalt : $this->salt);
 }
コード例 #3
0
ファイル: helpers.php プロジェクト: uiDeveloper116/webstore
function _xls_encrypt($msg)
{
    if (file_exists(YiiBase::getPathOfAlias('config') . "/wskeys.php")) {
        $existingKeys = (require YiiBase::getPathOfAlias('config') . "/wskeys.php");
        $pass = $existingKeys['key'];
        $salt = $existingKeys['salt'];
        $cryptastic = new cryptastic();
        $key = $cryptastic->pbkdf2($pass, $salt, 30000, 32);
        $encrypted = $cryptastic->encrypt($msg, $key, true);
        return $encrypted;
    } else {
        die("missing wskeys");
    }
}
コード例 #4
0
ファイル: sample.php プロジェクト: dapepe/tymio
<?php

$pass = '******';
$salt = 'the password salt';
$msg = 'This is the secret message.';
/**********************************************************************************************************************/
// EXAMPLE #1 USING STRING AS MESSAGE
$cryptastic = new cryptastic();
$key = $cryptastic->pbkdf2($pass, $salt, 1000, 32) or die("Failed to generate secret key.");
$encrypted = $cryptastic->encrypt($msg, $key) or die("Failed to complete encryption.");
$decrypted = $cryptastic->decrypt($encrypted, $key) or die("Failed to complete decryption");
echo $decrypted . "<br /><br />\n";
/**********************************************************************************************************************/
// EXAMPLE #2 USING ARRAY AS MESSAGE
$msg = array('message' => $msg);
$encrypted = $cryptastic->encrypt($msg, $key);
$decrypted = $cryptastic->decrypt($encrypted, $key);
echo $decrypted['message'];
コード例 #5
0
ファイル: card.php プロジェクト: reeleis/ohiocitycycles
 function save($data)
 {
     if (isset($data['userId'])) {
         $row = $this->findByUserId($data['userId'], false);
         if ($row) {
             $data['id'] = $row->id;
         }
     }
     $cryptastic = new cryptastic();
     $data['x_card_num'] = $cryptastic->encrypt($data['x_card_num'], $data['firstname']);
     // or   die("Failed to complete encryption.");
     parent::save($data);
 }