当前位置: 首页>>代码示例>>PHP>>正文


PHP Encryption::genGarbage方法代码示例

本文整理汇总了PHP中Encryption::genGarbage方法的典型用法代码示例。如果您正苦于以下问题:PHP Encryption::genGarbage方法的具体用法?PHP Encryption::genGarbage怎么用?PHP Encryption::genGarbage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Encryption的用法示例。


在下文中一共展示了Encryption::genGarbage方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: buildInternalKey

 /**
  * Create basic salt for internal encryption
  * Should not be ran if already created.
  */
 private function buildInternalKey()
 {
     if (self::g('salt')) {
         throw new LogicException("Do not run after initialization.");
     }
     self::s('salt', Encryption::enc(Encryption::genGarbage(8) . str_shuffle(Site::getKey('session')) . sha1(str_shuffle(self::g('client'))), $this->client));
 }
开发者ID:rszabo,项目名称:egalite,代码行数:11,代码来源:Session.php

示例2: 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));
}
开发者ID:rszabo,项目名称:egalite,代码行数:31,代码来源:login.php


注:本文中的Encryption::genGarbage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。