本文整理汇总了PHP中Encryption::enc方法的典型用法代码示例。如果您正苦于以下问题:PHP Encryption::enc方法的具体用法?PHP Encryption::enc怎么用?PHP Encryption::enc使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Encryption
的用法示例。
在下文中一共展示了Encryption::enc方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generate
public static function generate()
{
$sk = base64_encode(Encryption::enc(self::getData(), self::getSalt()));
return $sk;
}
示例2: setup
/**
* For newly created sessions initial data is required,
* such as client information, private salt and such.
*/
private function setup()
{
// No need?
if (self::g('client') != "") {
return;
}
// Setup!
self::s('client', Encryption::enc($this->client, Site::getKey('session')));
self::s('created', date("Y-m-d H:i:s"));
// Every Session use a unique key; see getInternalKey().
//
$this->buildInternalKey();
$this->set("end", "now.");
}
示例3: RuntimeException
if (!($jdata = json_decode($data, true))) {
throw new RuntimeException("Unable to parse input.");
}
if (empty($jdata["credentials"])) {
throw new RuntimeException("Received credentials are missing.");
}
// Read credentials
$cred_obj = explode(" ", base64_decode($jdata['credentials']));
if (count($cred_obj) < 2) {
throw new RuntimeException("Received credentials are malformed.");
}
// This is where you normally handle the call, i.e.. $res = Api::handleRequest($jdata);
// Username and passphrase successfully read.
$username = $cred_obj[0];
$passphrase = $cred_obj[1];
// Set asymmetric key to be used in future communication
$session = Session::getInstance();
$session->set(Session::TRANSPORT_KEY, Encryption::genGarbage(Session::KEYSIZE));
// Clear login key
$session->set(Captcha::KEY_LOGIN, null);
// Let's say that everything went well and Citizen $username was loaded successfully.
$res = array("id" => 123, "username" => $username, Session::STORAGE_KEY => base64_encode(Session::getStorageKey()), Session::TRANSPORT_KEY => base64_encode($session->get(Session::TRANSPORT_KEY)));
// This is where you normally pass $res (Api::handleRequest()) to whatever renderer is available.
/* Output */
$output = json_encode(array("result" => $res));
die(Encryption::enc($output, $key));
} catch (Exception $e) {
$output = json_encode(array("error" => array("code" => 1, "message" => $e->getMessage())));
trigger_error($e->getMessage());
die(Encryption::enc($output, $key));
}