예제 #1
0
파일: aes.php 프로젝트: simbacode/xcrypto
<?php

//
// Copyright (c) 2011 Scott Clayton
//
// This file is part of the C# to PHP Encryption Library.
//
// The C# to PHP Encryption Library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// The C# to PHP Encryption Library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with the C# to PHP Encryption Library.  If not, see <http://www.gnu.org/licenses/>.
//
use Simbacode\Xcrypto\Crypt\AES;
$aes = new AES();
$aes->setKey('abcdefghijklmnopabcdefghijklmnop');
$aes->setIV('abcdefghijklmnop');
$aes->setKeyLength(256);
echo base64_encode("abcdefghijklmnopabcdefghijklmnop") . "<BR>";
echo base64_encode("abcdefghijklmnop") . "<BR>";
$plaintext = 'llamas are super cool!';
echo base64_encode($aes->encrypt($plaintext)) . "<BR>";
echo $aes->decrypt($aes->encrypt($plaintext));
예제 #2
0
function SendEncryptedResponse($message)
{
    $aes = new AES(AES_MODE_CBC);
    $aes->setKeyLength(256);
    $aes->setKey(Base64UrlDecode($_SESSION['key']));
    $aes->setIV(Base64UrlDecode($_SESSION['iv']));
    $aes->enablePadding();
    // This is PKCS
    echo Base64UrlEncode($aes->encrypt($message));
    exit;
}
예제 #3
0
 /**
  *  Encrypts the message to be sent using AES.
  *  Make sure you have not output any other text before or after calling this.
  * 
  * @param String $message The message to be transported online
  */
 function SendEncryptedResponse($message)
 {
     $aes = new AES(AES_MODE_CBC);
     $aes->setKeyLength(256);
     $aes->setKey($this->Base64UrlDecode($this->key));
     $aes->setIV($this->Base64UrlDecode($this->iv));
     $aes->enablePadding();
     // This is PKCS
     echo $this->Base64UrlEncode($aes->encrypt($message));
     exit;
 }