本文整理汇总了PHP中Security::rijndael方法的典型用法代码示例。如果您正苦于以下问题:PHP Security::rijndael方法的具体用法?PHP Security::rijndael怎么用?PHP Security::rijndael使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Security
的用法示例。
在下文中一共展示了Security::rijndael方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: export
public static function export($encrypt = true)
{
if (!self::$connection) {
self::connect();
}
$tableActions = array();
$insertString = '';
$tables = mysql_query('SHOW TABLES');
while ($table = mysql_fetch_row($tables)) {
//Stuktur exportieren
$creationString = mysql_fetch_row(mysql_query('SHOW CREATE TABLE ' . $table[0]));
$insertString = "DROP TABLE IF EXISTS `" . $table[0] . "`;\n" . $creationString[1] . ";\n";
$fields = mysql_query('DESCRIBE `' . $table[0] . "`");
$insertHead = "\nINSERT INTO `" . $table[0] . "` (" . self::getInsertionHeadFormat($fields) . ") VALUES \n";
$data = mysql_query('SELECT * FROM `' . $table[0] . "`");
$dataArray = self::getInsertionDataArray($data);
$rowsPerInsert = 100;
$dataCount = count($dataArray);
for ($i = 0; $i < $dataCount; $i += $rowsPerInsert) {
$currentData = array_slice($dataArray, $i, $rowsPerInsert);
$insertString .= $insertHead;
$insertString .= implode(",\n ", $currentData) . ";";
}
array_push($tableActions, $insertString);
}
mysql_close();
$res = implode("\n\n\n", $tableActions);
if ($encrypt) {
$res = ENCRYPTIONSIGNAL . base64_encode(Security::rijndael($res, Configure::read('Security.key'), 'encrypt'));
}
return $res;
}
示例2: afterFind
public function afterFind($results = array(), $primary = false)
{
foreach ($this->encryptedFields as $fieldName) {
foreach ($results as $key => $value) {
if (!empty($results[$key][$this->alias][$fieldName])) {
$results[$key][$this->alias][$fieldName] = Security::rijndael($results[$key][$this->alias][$fieldName], Configure::read('Security.key'), 'decrypt');
}
}
}
return $results;
}
示例3: main
//.........这里部分代码省略.........
foreach ($tenants as $tenant) {
//Check to see if tenant has auto pay on
if (isset($tenant['AutoPayment']) && count($tenant['AutoPayment']) > 0 && $billing_cycle['Billing']['type'] == 'Rent') {
//If active and in time frame
if ($tenant['AutoPayment'][0]['active'] && (strtotime($tenant['AutoPayment'][0]['auto_start']) <= time() && time() <= strtotime($tenant['AutoPayment'][0]['auto_end']))) {
//$tenant['AutoPayment'][0]['vault_id']
//$tenant['AutoPayment'][0]['amount']
//Charge Fee based on ACH or CC
//Determine Transaction Fees
$pay_amount = $tenant['AutoPayment'][0]['amount'];
$total_amount = 0;
//Is selected payment CC or ACH
//ACH => Rent Total + recurring fee - free rent + fee $3.95 (fee only if tenant paying fees)
//CC/Debit - Rent Total + recurring fee - free rent + fee 2.75% (fee only if tenant percent)
//if ACH
//if tenant pays
//add $3.95
//else CC
//if tenant pays
//add2.75%
$i = 0;
foreach ($tenant['PaymentMethod'] as $paymentMethod) {
if ($paymentMethod['vault_id'] == $tenant['AutoPayment'][0]['vault_id']) {
$paymentType = $tenant['PaymentMethod'][$i]['type'];
break;
}
$i++;
}
if ($paymentType == 'CC') {
//Payment is Credit Card
if ($tenant['Property']['prop_pays_cc_fee']) {
$pay_fee = floatval($pay_amount) * floatval(CC_FEE);
$total_amount = floatval($pay_amount) - floatval($pay_fee);
$result = $this->Payment->processPayment($total_amount, $tenant['AutoPayment'][0]['vault_id'], $tenant['Property']['pp_user'], Security::rijndael($tenant['Property']['pp_pass'], Configure::read('Security.salt2'), 'decrypt'));
parse_str($result);
if (isset($response) && $response == 1) {
$auto_payment = array();
$auto_payment['Payment']['ppresponse'] = $response;
$auto_payment['Payment']['ppresponsetext'] = $responsetext;
$auto_payment['Payment']['ppauthcode'] = $authcode;
$auto_payment['Payment']['pptransactionid'] = $transactionid;
$auto_payment['Payment']['ppresponse_code'] = $response_code;
$auto_payment['Payment']['status'] = 'Complete';
$auto_payment['Payment']['type'] = 'Auto CC';
$auto_payment['Payment']['notes'] = 'Auto Payment';
$auto_payment['Payment']['user_id'] = $tenant['User']['id'];
$auto_payment['Payment']['billing_id'] = $billing_cycle['Billing']['id'];
$auto_payment['Payment']['unit_id'] = $billing_cycle['Billing']['unit_id'];
$auto_payment['Payment']['amount'] = $tenant['AutoPayment'][0]['amount'];
$auto_payment['Payment']['is_fee'] = 0;
$auto_payment['Payment']['amt_processed'] = floatval($total_amount);
$auto_payment['Payment']['total_bill'] = floatval($pay_amount);
//Add to Payments Table
$this->Payment->create();
if ($this->Payment->save($auto_payment)) {
$this->Billing->updatebillingstatus($billing_cycle['Billing']['id']);
$this->out($billing_cycle['Billing']['id'] . ' - Applied Auto Payment of ' . $tenant['AutoPayment'][0]['amount']);
//Send Email Payment was processed
$email_data['name'] = $tenant['User']['first_name'];
$email_data['amount'] = $total_amount;
$email_data['trans_id'] = $transactionid;
$email_data['unit_name'] = $billing_cycle['Unit']['number'];
$email_data['prop_name'] = $billing_cycle['Unit']['Property']['name'];
if ($this->__sendAutoPaymentSuccess($tenant['User']['email'], $email_data)) {
$this->out('Payment Received Email sent to ' . $tenant['User']['email']);
}
示例4: testRijndaelInvalidKey
/**
* testRijndaelInvalidKey method
*
* @expectedException PHPUnit_Framework_Error
* @return void
*/
public function testRijndaelInvalidKey()
{
$txt = 'The quick brown fox jumped over the lazy dog.';
$key = 'too small';
Security::rijndael($txt, $key, 'encrypt');
}
示例5: _decode
/**
* Decodes and decrypts a single value.
*
* @param string $value The value to decode & decrypt.
* @return string Decoded value.
*/
protected function _decode($value)
{
$prefix = 'Q2FrZQ==.';
$pos = strpos($value, $prefix);
if ($pos === false) {
return $this->_explode($value);
}
$value = base64_decode(substr($value, strlen($prefix)));
if ($this->_type === 'rijndael') {
$plain = Security::rijndael($value, $this->key, 'decrypt');
}
if ($this->_type === 'cipher') {
$plain = Security::cipher($value, $this->key);
}
if ($this->_type === 'aes') {
$plain = Security::decrypt($value, $this->key);
}
return $this->_explode($plain);
}
示例6: activateproperty
function activateproperty()
{
$this->adminCheck();
$this->loadModel('Property');
$property = $this->Property->find('list', array('conditions' => array('Property.active' => 0)));
$this->set(compact('property'));
if (!empty($this->request->data)) {
$data = $this->request->data;
$this->Property->id = $data['Property']['id'];
$data['Property']['pp_pass'] = Security::rijndael($data['Property']['pp_pass'], Configure::read('Security.salt2'), 'encrypt');
$data['Property']['active'] = 1;
//active property only after success payment.
if ($this->Property->save($data)) {
//Wave One Time Fee?
if ($data['Property']['no_one_time_fee']) {
$this->Session->setFlash('Property Activated Successfully. Waved signup fee.', 'flash_good');
$this->redirect(array('action' => 'index'));
}
//Charge One Time Setup Fee
$this->loadModel('Payment');
//Get Property Data
$property_data = $this->Property->findById($this->Property->id);
//Determine Cost base on number of units. If actual unit_count in system is greater
//than num_units provided by user, charge actual number
if ($property_data['Property']['num_units'] > $property_data['Property']['unit_count']) {
$amount = intval($this->get_monthly_fee($property_data['Property']['num_units'])) * 2;
} else {
$amount = intval($this->get_monthly_fee($property_data['Property']['unit_count'])) * 2;
}
//Process One Time Fee Payment to RentSquare
$result = $this->Payment->processPayment($amount, $property_data['Property']['vault_id'], RENTSQUARE_MERCH_USER, RENTSQUARE_MERCH_PASS);
parse_str($result);
if (isset($response) && $response == 1) {
$this->Property->id = $property_data['Property']['id'];
$this->Property->saveField('active', 1);
// 2014-09-15 - Wolff - Set fee_due_day
$this->Property->saveField('fee_due_day', date('j'));
$this->__sendPropertyActivation($property_data);
$signup_fee = array();
$signup_fee['Payment']['ppresponse'] = $response;
$signup_fee['Payment']['ppresponsetext'] = $responsetext;
$signup_fee['Payment']['ppauthcode'] = $authcode;
$signup_fee['Payment']['pptransactionid'] = $transactionid;
$signup_fee['Payment']['ppresponse_code'] = $response_code;
$signup_fee['Payment']['status'] = 'Complete';
$signup_fee['Payment']['notes'] = 'Signup Fee';
$signup_fee['Payment']['user_id'] = $property_data['Property']['manager_id'];
$signup_fee['Payment']['billing_id'] = 0;
$signup_fee['Payment']['unit_id'] = 0;
$signup_fee['Payment']['amount'] = $amount;
$signup_fee['Payment']['is_fee'] = 0;
$signup_fee['Payment']['amt_processed'] = floatval($amount);
$signup_fee['Payment']['total_bill'] = floatval($amount);
//Add to Payments Table
$this->Payment->create();
$this->Payment->save($signup_fee);
$this->Session->setFlash('Property Activated Successfully and One Time Fee Processed', 'flash_good');
$this->redirect(array('action' => 'index'));
} else {
$this->loadModel('FailedPayment');
$failed = $property_data;
$failed['FailedPayment']['billing_id'] = '0';
$failed['FailedPayment']['unit_id'] = '0';
$failed['FailedPayment']['user_id'] = $property_data['Property']['manager_id'];
$failed['FailedPayment']['amount'] = $amount;
$failed['FailedPayment']['ppresponse'] = $response;
$failed['FailedPayment']['ppresponsetext'] = $responsetext;
$failed['FailedPayment']['ppauthcode'] = $authcode;
$failed['FailedPayment']['pptransactionid'] = $transactionid;
$failed['FailedPayment']['ppresponse_code'] = $response_code;
$failed['FailedPayment']['notes'] = "Failed on One Time Fee Charge. Property id " . $property_data['Property']['id'];
if ($this->FailedPayment->save($failed)) {
$this->Session->setFlash(__('Payment has failed with error ' . $responsetext), 'flash_bad');
} else {
$this->Session->setFlash(__('Payment has failed with error ' . $responsetext), 'flash_bad');
}
}
} else {
$this->Session->setFlash('Error activating property.', 'flash_bad');
}
}
}
示例7: DecryptShopId
/**
* Decrypts the shop ID the transaction in question is related to.
*
* @param string $eShopId encrypted shop ID as supplied by SOFORT.com notify
* request
*/
public static function DecryptShopId($eShopId)
{
// URL param from CakePHP comes in decoded already
// but to handle + signs correctly we need to encode and decode again
$urlEncoded = urlencode($eShopId);
$base64 = rawurldecode($urlEncoded);
$encrypted = self::Base64Decode($base64);
return Security::rijndael($encrypted, Configure::read('Security.salt'), 'decrypt');
}
示例8: PaymentRedirect
/**
* Calls Sofortueberweisung::sendRequest and redirects the buyer to
* the payment url.
* @throws SofortLibException when Sofortueberweisung returns an error
* @throws InvalidArgumentException when no shop_id has been set.
*/
public function PaymentRedirect()
{
if (empty($this->shop_id)) {
throw new InvalidArgumentException("No shop_id set.");
}
$eShopId = rawurlencode(self::Base64Encode(Security::rijndael($this->shop_id, Configure::read('Security.salt'), 'encrypt')));
$notificationUrl = Router::url('/SofortComPayment/Notify/' . $eShopId, true);
foreach ($this->states as $state) {
$this->Sofortueberweisung->setNotificationUrl($notificationUrl . '/' . $state, $state);
}
App::uses('SofortComShopTransaction', 'SofortCom.Model');
$SofortComShopTransaction = new SofortComShopTransaction();
$this->Sofortueberweisung->sendRequest();
if ($this->Sofortueberweisung->isError()) {
$error = $this->Sofortueberweisung->getError();
$exception = new SofortLibRequestException($error);
$exception->errors = $this->Sofortueberweisung->getErrors();
throw $exception;
}
$transaction = $this->Sofortueberweisung->getTransactionId();
$payment_url = $this->Sofortueberweisung->getPaymentUrl();
$SofortComShopTransaction->Add($transaction, $this->shop_id);
if (!empty($this->newTransactionCallback) && is_callable($this->newTransactionCallback)) {
$args = array($transaction, $payment_url);
call_user_func_array($this->newTransactionCallback, array_merge($args, $this->newTransactionCallbackArgs));
}
header('Location: ' . $payment_url);
exit;
}
示例9: passwordDecrypt
/**
* パスワードの複合化
* @param type $user_password
* @return string
*/
public function passwordDecrypt($user_password)
{
$password = base64_decode($user_password);
return Security::rijndael($password, self::CIPHER_KEY, 'decrypt');
}
示例10: delete
/**
* delete method
*
* @param string $id
* @return void
*/
public function delete($id = null)
{
if (isset($this->request->data['PaymentMethod']['id'])) {
$id = $this->request->data['PaymentMethod']['id'];
}
if (!$this->request->is('post')) {
throw new MethodNotAllowedException();
}
$this->PaymentMethod->id = $id;
if (!$this->PaymentMethod->exists()) {
throw new NotFoundException(__('Invalid payment method'));
}
if ($this->PaymentMethod->delete()) {
$this->loadModel('Property');
$prop = $this->Property->findById($this->Auth->user('property_id'));
//Get Phoenix Payment Password
$pp_password = Security::rijndael($prop['Property']['pp_pass'], Configure::read('Security.salt2'), 'decrypt');
$paymentmethod['user_id'] = $id;
$paymentmethod['pp_user'] = $prop['Property']['pp_user'];
$paymentmethod['pp_password'] = $pp_password;
$this->PaymentMethod->delete_from_vault($paymentmethod);
$this->Session->setFlash(__('Payment method deleted'), 'flash_good');
$this->redirect(array('controller' => 'Users', 'action' => 'myaccount', 'payment_methods'));
}
$this->Session->setFlash(__('Payment method was not deleted'), 'flash_bad');
$this->redirect(array('controller' => 'Users', 'action' => 'myaccount', 'payment_methods'));
}
示例11: _decrypt
protected function _decrypt($idul, $encrypted)
{
return substr(Security::rijndael($encrypted, Configure::read('Security.key'), 'decrypt'), strlen($idul . Configure::read('Security.salt')));
}
示例12: cross_domain_login
public function cross_domain_login()
{
$tokeno = $this->request->query['token'];
$token = base64_decode($tokeno);
$token = Security::rijndael($token, Configure::read('Security.salt'), 'decrypt');
$token = explode(' ', $token);
if (count($token) != 3 or $token[2] != CROSSDOMAIN_salt) {
throw new BadRequestException();
}
$uid = $token[1];
if ($this->Auth->loggedIn()) {
// logout if different user
if ($this->Auth->user('id') != $uid) {
$this->Auth->logout();
}
}
$userCl = new User();
$user = $userCl->read($uid);
if (empty($user)) {
throw new Exception("Was expecting user data");
}
// login this user
$this->Auth->login($user);
// no view
$this->layout = 'ajax';
$this->render(false);
}
示例13: payrent
function payrent()
{
if ($this->request->is('post') || $this->request->is('put')) {
$data = $this->request->data;
$pay_amount = $data['Payment']['amount'];
//Determine Transaction Fees
$this->loadModel('User');
$this->User->contain('Property', 'PaymentMethod', 'Unit');
$user = $this->User->find('first', array('conditions' => array('User.id' => $this->Auth->user('id'))));
//Is selected payment CC or ACH
$i = 0;
$paymentType = "";
foreach ($user['PaymentMethod'] as $paymentMethod) {
if ($paymentMethod['vault_id'] == $data['Payment']['vault_id']) {
$paymentType = $user['PaymentMethod'][$i]['type'];
break;
}
$i++;
}
if ($paymentType == 'CC') {
//Payment is Credit Card
if ($user['Property']['prop_pays_cc_fee']) {
$amount = floatval($pay_amount);
$amt_fee = $amount * floatval(CC_FEE);
$amt_processed = floatval($amount) - $amt_fee;
$total_bill = floatval($pay_amount);
} else {
$amount = floatval($pay_amount);
$amt_fee = $amount * floatval(CC_FEE);
$amt_processed = floatval($amount);
$total_bill = floatval($amt_processed) + floatval($amt_fee);
}
} else {
//Payment is ACH
if ($user['Property']['prop_pays_ach_fee']) {
$amount = floatval($pay_amount);
$amt_fee = floatval(ACH_FEE);
$amt_processed = floatval($amount) - $amt_fee;
$total_bill = floatval($amount);
} else {
$amount = floatval($pay_amount);
$amt_fee = floatval(ACH_FEE);
$amt_processed = floatval($amount);
$total_bill = floatval($amount) + floatval(ACH_FEE);
}
}
$pp_password = Security::rijndael($user['Property']['pp_pass'], Configure::read('Security.salt2'), 'decrypt');
//Submit Payment
$result = $this->Payment->processPayment($amt_processed, $data['Payment']['vault_id'], $user['Property']['pp_user'], $pp_password);
parse_str($result);
if (isset($response) && $response == 1) {
$this->loadModel('Billing');
$amt_process_transid = $transactionid;
$data['Payment']['ppresponse'] = $response;
$data['Payment']['ppresponsetext'] = $responsetext;
$data['Payment']['ppauthcode'] = $authcode;
$data['Payment']['pptransactionid'] = $transactionid;
$data['Payment']['ppresponse_code'] = $response_code;
$data['Payment']['status'] = 'Complete';
$data['Payment']['user_id'] = $this->Auth->user('id');
$data['Payment']['type'] = $paymentType;
$data['Payment']['is_fee'] = 0;
$data['Payment']['amt_processed'] = floatval($amt_processed);
$data['Payment']['total_bill'] = floatval($total_bill);
//If Payment id = 0 (AKA pay toward current balance)
if ($data['Payment']['billing_id'] == 0) {
$this->loadModel('Billing');
$billing_ids = $this->Billing->find('all', array('conditions' => array('status !=' => 'paid', 'unit_id' => $data['Payment']['unit_id']), 'fields' => array('id', 'rent_due', 'unit_id'), 'order' => array('Billing.id')));
$total_payment = floatval($data['Payment']['amount']);
$failed = 0;
//For each open billing id associated to unit
foreach ($billing_ids as $billing_id) {
//get how much is due including payments have been made
$total_due = floatval($billing_id['Billing']['rent_due']);
if (isset($billing_id['Payment'])) {
foreach ($billing_id['Payment'] as $payment) {
$total_due = $total_due - floatval($payment['amount']);
}
// $billing_id['Payment'] as $payment
}
if (floatval($total_payment) > 0) {
$data['Payment']['billing_id'] = $billing_id['Billing']['id'];
if ($total_due < $total_payment) {
$data['Payment']['amount'] = floatval($total_due);
} else {
$data['Payment']['amount'] = floatval($total_payment);
}
$this->Payment->create();
if ($this->Payment->save($data)) {
$this->loadModel('Billing');
$this->Billing->updatebillingstatus($billing_id['Billing']['id']);
$total_payment = $total_payment - $total_due;
} else {
$failed = $billing_id['Billing']['id'];
}
}
}
//$billing_ids as $billing_id
// if $total_payment > 0 add credit to account
if ($total_payment > 0 && !$failed) {
//.........这里部分代码省略.........
示例14: _encrypt
/**
* Encrypts $value using public $type method in Security class
*
* @param string $value Value to encrypt
*
* @return string Encoded values
*/
protected function _encrypt($value)
{
if (is_array($value)) {
$value = $this->_implode($value);
}
if (!$this->_encrypted) {
return $value;
}
$prefix = "Q2FrZQ==.";
if ($this->_type === 'rijndael') {
$cipher = Security::rijndael($value, $this->key, 'encrypt');
}
if ($this->_type === 'cipher') {
$cipher = Security::cipher($value, $this->key);
}
if ($this->_type === 'aes') {
$cipher = Security::encrypt($value, $this->key);
}
return $prefix . base64_encode($cipher);
}