本文整理汇总了PHP中Key类的典型用法代码示例。如果您正苦于以下问题:PHP Key类的具体用法?PHP Key怎么用?PHP Key使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Key类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: I18nRouter
/**
* Construcctor de I18nRouter
* llena $__routes y crea la instancia del modelo que se encarga de interpretar las rutas
* @access public
* @return void
*/
function I18nRouter()
{
$this->__setLocale();
$this->__resortLangs();
$key = new Key();
$this->__urlsKey = $key->getUrls();
}
示例2: test_not_mandatory_extra_validator_should_pass_with_absent_key
public function test_not_mandatory_extra_validator_should_pass_with_absent_key()
{
$subValidator = new Length(1, 3);
$validator = new Key('bar', $subValidator, false);
$obj = array();
$this->assertTrue($validator->validate($obj));
}
示例3: getSharedSecret
/**
* Diffie-Hellman, ECDHE, etc.
*
* Get a shared secret from a private key you possess and a public key for
* the intended message recipient
*
* @param EncryptionSecretKey $privateKey
* @param EncryptionPublicKey $publicKey
* @param bool $get_as_object Get as a Key object?
* @return string
*/
public static function getSharedSecret(Key $privateKey, Key $publicKey, bool $get_as_object = false)
{
if ($get_as_object) {
return new EncryptionKey(\Sodium\crypto_scalarmult($privateKey->getRawKeyMaterial(), $publicKey->getRawKeyMaterial()));
}
return \Sodium\crypto_scalarmult($privateKey->getRawKeyMaterial(), $publicKey->getRawKeyMaterial());
}
示例4: testNotMandatoryExtraValidatorShouldPassWithAbsentKey
public function testNotMandatoryExtraValidatorShouldPassWithAbsentKey()
{
$subValidator = new Length(1, 3);
$validator = new Key('bar', $subValidator, false);
$obj = array();
$this->assertTrue($validator->validate($obj));
}
示例5: assert_that_key_usage_check_works_correctly
/**
* @group certificate
*
* @test
*/
public function assert_that_key_usage_check_works_correctly()
{
$key = new Key(array(Key::USAGE_SIGNING => true));
$this->assertTrue($key->canBeUsedFor(Key::USAGE_SIGNING));
$this->assertFalse($key->canBeUsedFor(Key::USAGE_ENCRYPTION));
$key[Key::USAGE_ENCRYPTION] = false;
$this->assertFalse($key->canBeUsedFor(Key::USAGE_ENCRYPTION));
}
示例6: getKeys
/** @return Key[] */
public function getKeys()
{
$keys = [];
$keysNames = $this->predis->smembers($this->getKeyName("tag:{$this->key}"));
foreach ($keysNames as $key) {
$k = new Key($this->predis, $key);
$k->setKeyPrefix($this->keyPrefix);
$keys[] = $k;
}
return $keys;
}
示例7: up
/**
* Make changes to the database.
*
* @return void
*/
public function up()
{
Schema::create('keys', function ($table) {
$table->increments('id');
$table->string('name');
$table->string('api_key');
$table->timestamps();
});
$key = new Key();
$key->name = "default";
$key->api_key = Config::get('solder.platform_key');
$key->save();
}
示例8: __construct
/**
* @param array $keys
*/
public function __construct(array $keys)
{
if (!empty($keys)) {
foreach ($keys as $value) {
$key = new Key();
$key->setKey(isset($value['key']) ? $value['key'] : null);
$key->setValue(isset($value['value']) ? $value['value'] : null);
$key->setCas(isset($value['cas']) ? $value['cas'] : null);
$this->addKey($value['key'], $key);
}
//sort the keys
ksort($this->keys);
}
}
示例9: assert_that_offsetunset_unsets_offset
/**
* @group certificate
*
* @test
*/
public function assert_that_offsetunset_unsets_offset()
{
$key = new Key(array(Key::USAGE_SIGNING => true, Key::USAGE_ENCRYPTION => true));
$this->assertTrue($key->offsetExists(Key::USAGE_SIGNING));
$this->assertTrue($key->offsetExists(Key::USAGE_ENCRYPTION));
$key->offsetUnset(Key::USAGE_SIGNING);
$this->assertFalse($key->offsetExists(Key::USAGE_SIGNING));
$this->assertTrue($key->offsetExists(Key::USAGE_ENCRYPTION));
$key->offsetUnset(Key::USAGE_ENCRYPTION);
$this->assertFalse($key->offsetExists(Key::USAGE_SIGNING));
$this->assertFalse($key->offsetExists(Key::USAGE_ENCRYPTION));
}
示例10: showFP
function showFP()
{
$db = new PHPWS_DB('ps_page');
$db->addWhere('front_page', 1);
if ($db->isTableColumn('deleted')) {
$db->addWhere('deleted', 0);
}
Key::restrictView($db, 'pagesmith');
$db->loadClass('pagesmith', 'PS_Page.php');
$result = $db->getObjects('PS_Page');
if (!PHPWS_Error::logIfError($result) && !empty($result)) {
PHPWS_Core::initModClass('pagesmith', 'PageSmith.php');
foreach ($result as $page) {
$content = $page->view();
if ($content && !PHPWS_Error::logIfError($content)) {
if (Current_User::allow('pagesmith', 'edit_page', $page->id)) {
$content .= sprintf('<p class="pagesmith-edit">%s</p>', $page->editLink());
}
Layout::add($content, 'pagesmith', 'view_' . $page->id, TRUE);
}
}
} else {
return null;
}
}
示例11: testMultiChangePassword
public function testMultiChangePassword()
{
$firstPassword = 'hello world';
$secondPassword = 'goodbye sun';
$otpKey = 'I am a test key';
$data = openssl_random_pseudo_bytes(117);
// Set up a user
$user = new User();
$user->setOtpKey($otpKey, $firstPassword);
// Setup a key
$defaultKeyPassphrase = $user->dangerouslyRegenerateAccountKeyPassphrase($firstPassword);
$key = Key::generate($defaultKeyPassphrase, 1024);
$user->accountKey = $key;
// Encrypt some data
$encryptedData = $user->getAccountKey()->encrypt($data);
// Change user's password
// This must update the password on the default key and OTP key as well
$user->changePassword($firstPassword, $secondPassword);
// Decrypt data
$newKeyPassphrase = $user->getAccountKeyPassphrase($secondPassword);
$decrypted = $user->getAccountKey()->decrypt($encryptedData, $newKeyPassphrase);
// Default Key passphrase should have changed and remain valid
$this->assertNotEquals($newKeyPassphrase, $defaultKeyPassphrase);
$this->assertEquals($data, $decrypted);
// OTP key should have been encrypted with the new password
$this->assertEquals($otpKey, $user->getOtpKey($secondPassword));
}
示例12: Create
public static function Create($Key = 0, $Company = false)
{
$Return = false;
if ($Key !== 0) {
if (\Session::exists("refKey")) {
if (\Session::get("refKey") != $Key) {
//This computer has multiple Keys? I'm not sure how or why this would happen.
//It is a possibility so I guess I should probably plan for it
$SavedKey = new Key(\Session::get("refKey"));
if ($SavedKey->validKey()) {
//Has two valid keys? What on earth? I will have to account for this later
} else {
\Session::put("refKey", $Key);
$Return = true;
}
}
} else {
\Session::put("refKey", $Key);
$Return = true;
}
if (\Cookie::exists("refKey")) {
if (\Cookie::get("refKey") != $Key) {
$SavedKey = new Key(\Cookie::get("refKey"));
if ($SavedKey->validKey()) {
//Has two valid keys? What on earth? I will have to account for this later
} else {
\Cookie::put("refKey", $Key, \Config::get("tracking/cookie_expiry"));
$Return = true;
}
}
} else {
\Cookie::put("refKey", $Key, \Config::get("tracking/cookie_expiry"));
$Return = true;
}
if ($Company != false) {
if (count(\DB::getInstance()->table("companyip")->where("IP", \Connection::IP())->where("Company", $Company->ID())) == 0) {
\DB::getInstance()->table("companyip")->insert(array("IP" => \Connection::IP(), "Company" => $Company->ID(), "LastScene" => \Time::get(), "Hits" => 1));
} else {
\DB::getInstance()->table("companyip")->where("IP", \Connection::IP())->increment("Hits");
}
}
//IP Based Search will go here
return $Return;
}
return false;
}
示例13: getUserKeys
/**
* Get a map of id => name for the keys belonging to $this->user
*
* @return array
*/
protected function getUserKeys()
{
$keyMap = [];
$keys = Key::find(['user_id = :user_id:', 'bind' => ['user_id' => $this->user->id]]);
foreach ($keys as $key) {
$keyMap[$key->id] = $key->name;
}
return $keyMap;
}
示例14: action_do_delete
public function action_do_delete($key_id)
{
$key = Key::find($key_id);
if (empty($key)) {
return Redirect::back();
}
$key->delete();
return Redirect::to('key/list')->with('success', 'API Key deleted!');
}
示例15: postDelete
public function postDelete($key_id)
{
$key = Key::find($key_id);
if (empty($key)) {
return Redirect::to('key/list')->withErrors(new MessageBag(array('Platform Key not found')));
}
$key->delete();
Cache::forget('keys');
return Redirect::to('key/list')->with('success', 'API Key deleted!');
}