Exemple #1
0
 public function testLibsodiumDetection()
 {
     $this->assertTrue(Halite::isLibsodiumSetupCorrectly());
 }
Exemple #2
0
        exit(255);
    }
}
if (!isset($_SERVER['REQUEST_URI'])) {
    $_SERVER['REQUEST_URI'] = '';
}
/**
 * 2. Load the Airship functions
 */
require_once ROOT . '/Airship.php';
/**
 * 3. Let's autoload the composer packages
 */
require_once \dirname(ROOT) . '/vendor/autoload.php';
// Let's also make sure we're using a good version of libsodium
if (!Halite::isLibsodiumSetupCorrectly()) {
    die("Airship requires libsodium 1.0.9 or newer (with a stable version of the PHP bindings).");
}
/**
 * 4. Autoload the Engine files
 */
\Airship\autoload('Airship\\Alerts', '~/Alerts');
\Airship\autoload('Airship\\Engine', '~/Engine');
/**
 * 5. Load up the registry singleton for latest types
 */
$state = State::instance();
// 5a. Initialize the Gears.
require_once ROOT . '/gear_init.php';
/**
 * 6. Load the global functions
Exemple #3
-1
 public function testEncoding()
 {
     $random_bytes = \random_bytes(31);
     // Backwards compatibility:
     $encoder = Halite::chooseEncoder(false);
     $this->assertSame(Hex::encode($random_bytes), $encoder($random_bytes));
     $encoder = Halite::chooseEncoder(true);
     $this->assertSame(null, $encoder);
     // New encoding in version 3:
     $encoder = Halite::chooseEncoder(Halite::ENCODE_HEX);
     $this->assertSame(Hex::encode($random_bytes), $encoder($random_bytes));
     $encoder = Halite::chooseEncoder(Halite::ENCODE_BASE32);
     $this->assertSame(Base32::encode($random_bytes), $encoder($random_bytes));
     $encoder = Halite::chooseEncoder(Halite::ENCODE_BASE32HEX);
     $this->assertSame(Base32Hex::encode($random_bytes), $encoder($random_bytes));
     $encoder = Halite::chooseEncoder(Halite::ENCODE_BASE64);
     $this->assertSame(Base64::encode($random_bytes), $encoder($random_bytes));
     $encoder = Halite::chooseEncoder(Halite::ENCODE_BASE64URLSAFE);
     $this->assertSame(Base64UrlSafe::encode($random_bytes), $encoder($random_bytes));
 }