public function testCryptDecrypt() { $str = 'Ceci est un test hyper important !!'; $ec = new EdnaoCryptography(); $encoded = $ec->crypt($str); $decoded = $ec->decrypt($encoded); $this->assertNotEmpty($encoded); $this->assertEquals($str, $decoded); }
/** * Get decrypted token * @param string $str Encoded token * @return Array Token data array */ public function getTokenDecrypt($str) { // Old method $token = $this->ednaoCrypt->decrypt(urldecode($str)); if (!$token) { // New method $token = $this->ednaoCrypt->decrypt($str); } return Token::unserialize($token); }
public static function iframe($baseUrl, $socle, $version, $product, array $rights, $page) { $token = new Token($socle, $product, $rights); $ednaoCrypt = new EdnaoCryptography(); $ednaoCrypt->setPublicKey(file_get_contents(__DIR__ . '/../../var/auth/public.pem')); $tokenManager = new TokenManager($ednaoCrypt); $encodedToken = $tokenManager->getTokenCrypt($token); $loginUrl = sprintf('/naoned/%s/%s/%s', $encodedToken, urlencode($version), urlencode($page)); return sprintf('<iframe src="" frameborder="1" marginheight="0" marginwidth="0" width="400" height="600" id="ednao" data-login-path="%s" data-base-url="%s" data-context-path="%s" style="%s" > <p>Votre navigateur ne supporte pas l’élément iframe, l’aide ne peut donc pas être affichée</p> </iframe>', $loginUrl, $baseUrl, self::CONTEXT_PATH, self::style()); }