示例#1
0
 /**
  * @covers ::__construct
  * @covers ::reveal
  */
 public function testMaskingStringLongerThanNoiseLength()
 {
     $noise = SecretKey::getKey();
     $noise_length = mb_strlen($noise, '8bit');
     $string = str_repeat('asdf', $noise_length);
     $secret = new Secret($string);
     $this->assertSame($string, $secret->reveal(), 'Secret was destroyed');
 }
 /**
  * set up test environment
  */
 public function setUp()
 {
     if (PHP_MAJOR_VERSION === 7 && PHP_MINOR_VERSION >= 1) {
         $this->markTestSkipped('Will fail from PHP 7.1 on anyway because of deprecation notice.');
     }
     Secret::switchBacking(Secret::BACKING_MCRYPT);
 }
示例#3
0
 public function __construct($id, $titre, $table, $banque_name, $numero, $type_compte)
 {
     parent::__construct($id, $titre, $table);
     $this->banque_name = $banque_name;
     $this->numero = $numero;
     $this->type_compte = $type_compte;
 }
示例#4
0
 public function __construct($id, $titre, $table, $utilisateur, $password, $url, $description)
 {
     parent::__construct($id, $titre, $table);
     $this->utilisateur = $utilisateur;
     $this->password = $password;
     $this->url = $url;
     $this->description = $description;
 }
示例#5
0
 public function __construct($id, $titre, $table, $titulaire, $numero, $date_expiration, $type_cb)
 {
     parent::__construct($id, $titre, $table);
     $this->titulaire = $titulaire;
     $this->numero = $numero;
     $this->date_expiration = $date_expiration;
     $this->type_cb = $type_cb;
 }
示例#6
0
 /**
  * constructor
  *
  * @api
  * @param  array  $propertyData  the property data
  */
 public function __construct(array $propertyData = [])
 {
     foreach ($propertyData as $section => $values) {
         foreach (array_keys($values) as $key) {
             if (substr($key, -8) === 'password') {
                 $propertyData[$section][$key] = Secret::create($values[$key]);
             }
         }
     }
     $this->propertyData = $propertyData;
 }
示例#7
0
 public function __construct($id, $titre, $table, $application, $version, $description, $societe, $url, $numero, $clef, $date_achat, $nom, $email, $notes)
 {
     parent::__construct($id, $titre, $table);
     $this->application = $application;
     $this->version = $version;
     $this->description = $description;
     $this->societe = $societe;
     $this->url = $url;
     $this->numero = $numero;
     $this->clef = $clef;
     $this->date_achat = $date_achat;
     $this->nom = $nom;
     $this->email = $email;
     $this->notes = $notes;
 }
示例#8
0
 function save($data)
 {
     App::import("Vendor", "Secret", array('file' => 'Secret.php'));
     $salt = Secret::getSlat();
     $secret_password = Security::hash($data["password"], 'sha1', $salt);
     $user_name = $data["username"];
     if (!$this->getByUserName($user_name)) {
         $this->plan_db->addField($user_name);
         $this->plan_db->addField($data["user_type"]);
         $this->plan_db->addField($data["login_type"]);
         $this->plan_db->addField($salt);
         $this->plan_db->addField($secret_password);
         $this->plan_db->endRow();
         $this->plan_db->append();
         return true;
     } else {
         return false;
     }
 }
示例#9
0
 /**
  */
 function read($data, $key)
 {
     return Secret::read($key, $data);
 }
示例#10
0
文件: login.php 项目: Artea/freebeer
/**
 * $Horde: horde/login.php,v 2.154 2004/02/11 22:17:05 chuck Exp $
 *
 * Copyright 1999-2004 Charles J. Hagenbuch <*****@*****.**>
 * Copyright 1999-2004 Jon Parise <*****@*****.**>
 *
 * See the enclosed file COPYING for license information (LGPL). If you
 * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
 */
@define('AUTH_HANDLER', true);
@define('HORDE_BASE', dirname(__FILE__));
require_once HORDE_BASE . '/lib/base.php';
require_once HORDE_LIBS . 'Horde/Menu.php';
require_once HORDE_LIBS . 'Horde/Secret.php';
/* Initialize the Auth credentials key. */
Secret::setKey('auth');
/* Get an Auth object. */
$auth =& Auth::singleton($conf['auth']['driver']);
if (is_a($auth, 'PEAR_Error')) {
    Horde::fatal($auth, __FILE__, __LINE__);
}
/* Get parameters. */
$logout_reason = $auth->getLogoutReason();
$url_param = Util::getFormData('url');
if ($logout_reason) {
    $login_screen = $auth->_getLoginScreen();
    if (Util::removeParameter($login_screen, array('url', 'nocache')) != Util::removeParameter(Horde::url(Horde::selfUrl(), true), array('url', 'nocache'))) {
        $url = Auth::addLogoutParameters($login_screen);
        if ($url_param) {
            $url = Util::addParameter($login_screen, 'url', $url_param);
        }
示例#11
0
 /**
  */
 function read($data, $key)
 {
     $data = @pack("H" . strlen($data), $data);
     return Secret::read($key, $data);
 }
 /**
  * set up test environment
  */
 public function setUp()
 {
     Secret::switchBacking(Secret::BACKING_OPENSSL);
 }
示例#13
0
 /**
  * @test
  */
 public function canSwitchBackingWhenAllSecretInstancesDestroyed()
 {
     $secret = Secret::create('payload');
     $secret = null;
     expect(function () {
         assertTrue(Secret::switchBacking(Secret::BACKING_PLAINTEXT));
     })->doesNotThrow();
 }
 private function getFacebook()
 {
     include "app/controllers/secret_controller.php";
     $facebookAppSecretToken = Secret::getSecret();
     $facebookRawFeed = file_get_contents($facebookAppSecretToken);
     $facebookJson = json_decode($facebookRawFeed, TRUE);
     return $facebookJson;
 }
<?php

include './Secret.php';
define('URL_QIITA_API', 'https://qiita.com/api/v2/items/');
$url = parse_url($_POST['url']);
if (strpos($url['host'], 'qiita.com') === false) {
    error_log("not qiita.com");
    exit;
}
$itemId = explode('/', $url['path'])[3];
error_log('stocking item id: ' . $itemId);
$url = URL_QIITA_API . $itemId . '/stock';
$qiitaAccessToken = Secret::getQiita();
if (function_exists('curl_init')) {
    $ch = curl_init();
    curl_setopt_array($ch, [CURLOPT_PUT => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_URL => $url, CURLOPT_HTTPHEADER => ['Content-type: application/json', 'Authorization: Bearer ' . $qiitaAccessToken]]);
    $response = curl_exec($ch);
    if ($response === false) {
        error_log('Qiita API response error: curl failed. ' . curl_error($ch));
    }
} else {
    $context = ['http' => ['method' => 'PUT', 'header' => 'Content-type: application/json' . "\r\n" . 'Authorization: Bearer ' . $qiitaAccessToken . "\r\n"]];
    $context = stream_context_create($context);
    $response = file_get_contents($url, false, $context);
    if ($response === false) {
        error_log('Qiita API response error');
        exit;
    }
}
error_log('Success qiita stock');
 /**
  * set up test environment
  */
 public function setUp()
 {
     Secret::switchBacking(Secret::BACKING_PLAINTEXT);
 }
示例#17
0
文件: Horde.php 项目: justinlyon/scc
 /**
  * Destroys any existing session on login and make sure to use a new
  * session ID, to avoid session fixation issues. Should be called before
  * checking a login.
  */
 function getCleanSession()
 {
     // Make sure to force a completely new session ID and clear all
     // session data.
     if (version_compare(PHP_VERSION, '4.3.3') !== -1) {
         session_regenerate_id(true);
         session_unset();
     } else {
         $old_error = error_reporting(0);
         session_destroy();
         error_reporting($old_error);
         if (Util::extensionExists('posix')) {
             $new_session_id = md5(microtime() . posix_getpid());
         } else {
             $new_session_id = md5(uniqid(mt_rand(), true));
         }
         session_id($new_session_id);
         // Restart the session, including setting up the session handler.
         Horde::setupSessionHandler();
         error_reporting(0);
         session_start();
         error_reporting($old_error);
     }
     /* Reset cookie timeouts, if necessary. */
     if (!empty($GLOBALS['conf']['session']['timeout'])) {
         $app = $GLOBALS['registry']->getApp();
         if (Secret::clearKey($app)) {
             Secret::setKey($app);
         }
         Secret::setKey('auth');
     }
 }
示例#18
0
    }
    /**
     * returns length of string
     *
     * @return  int
     */
    public function length() : int
    {
        return self::$store[$this->id]['length'];
    }
    /**
     * prevent serialization
     *
     * @throws  \LogicException
     */
    public function __sleep()
    {
        throw new \LogicException('Cannot serialize instances of ' . get_class($this));
    }
    /**
     * override regular __toString() output
     *
     * @return string
     */
    public function __toString()
    {
        return get_class($this) . " {\n}\n";
    }
}
Secret::__static();
示例#19
0
for ($i = 0; $i < count($ignore_user); $i++) {
    $classifier->train('search_user', $ignore_user[$i]);
}
for ($i = 0; $i < count($ignore_cat); $i++) {
    $classifier->train('search_category', $ignore_cat[$i]);
}
$query = $_POST['query'];
$result = $classifier->classify($query);
if ($result["search_user"] > $result["search_category"]) {
    $result = $query;
    for ($i = 0; $i < count($ignore_user); $i++) {
        $result = str_replace($ignore_user[$i], "", $result);
    }
    $u = new User();
    $r = $u->like("username", $result, false);
    for ($i = 0; $i < count($r); $i++) {
        //( ͡° ͜ʖ ͡°)
        $r[$i]["pw"] = "7w7";
    }
    echo json_encode((array) $r);
} elseif ($result["search_user"] == 0.5) {
    echo "I'm not sure...";
} else {
    $result = $query;
    for ($i = 0; $i < count($ignore_cat); $i++) {
        $result = str_replace($ignore_cat[$i], "", $result);
    }
    $s = new Secret();
    $r = $s->like("category", $result, false);
    echo json_encode((array) $r);
}
示例#20
0
文件: secrets.php 项目: haoa2/SS
<?php

require_once '../model/secret.php';
require_once '../model/likes.php';
require_once '../model/bin/logger.php';
$Secret = new Secret();
$Logger = new Logger();
$Like = new Like();
$action = isset($_GET['action']) ? $_GET['action'] : $_POST['action'];
switch ($action) {
    case 'all':
        $p = [];
        if (isset($_POST["limit"])) {
            $p["limit"] = $_POST["limit"];
        }
        if (isset($_POST["offset"])) {
            $p["offset"] = $_POST["offset"];
        }
        $r = $Secret->all($p);
        get_likes($r);
        for ($i = 0; $i < count($r); $i++) {
            $Logger->log("r[{$i}][id]:" . $r[$i]["id"], false);
        }
        echo json_encode($r);
        break;
    case 'get':
        $r = $Secret->find_by("category", $_POST['category'], false);
        $Logger->log("Secrets::get " . serialize($_POST));
        $Logger->log($r);
        echo json_encode($r);
        break;