You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shindig.apache.org by ch...@apache.org on 2008/08/23 15:59:11 UTC
svn commit: r688326 -
/incubator/shindig/trunk/php/src/common/samplecontainer/Crypto.php
Author: chabotc
Date: Sat Aug 23 06:59:10 2008
New Revision: 688326
URL: http://svn.apache.org/viewvc?rev=688326&view=rev
Log:
SHINDIG-528 by Artemy Tregubenko: Fix crypto in unicode environment
Modified:
incubator/shindig/trunk/php/src/common/samplecontainer/Crypto.php
Modified: incubator/shindig/trunk/php/src/common/samplecontainer/Crypto.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/common/samplecontainer/Crypto.php?rev=688326&r1=688325&r2=688326&view=diff
==============================================================================
--- incubator/shindig/trunk/php/src/common/samplecontainer/Crypto.php (original)
+++ incubator/shindig/trunk/php/src/common/samplecontainer/Crypto.php Sat Aug 23 06:59:10 2008
@@ -1,4 +1,5 @@
<?php
+
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -91,11 +92,19 @@
{
/* Open the cipher */
$td = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', MCRYPT_MODE_CBC, '');
- $iv = substr($encrypted_text, 0, Crypto::$CIPHER_BLOCK_SIZE);
+ if (is_callable('mb_substr')) {
+ $iv = mb_substr($encrypted_text, 0, Crypto::$CIPHER_BLOCK_SIZE, 'latin1');
+ } else {
+ $iv = substr($encrypted_text, 0, Crypto::$CIPHER_BLOCK_SIZE);
+ }
/* Initialize encryption module for decryption */
mcrypt_generic_init($td, $key, $iv);
/* Decrypt encrypted string */
- $encrypted = substr($encrypted_text, Crypto::$CIPHER_BLOCK_SIZE);
+ if (is_callable('mb_substr')) {
+ $encrypted = mb_substr($encrypted_text, Crypto::$CIPHER_BLOCK_SIZE, mb_strlen($encrypted_text, 'latin1'), 'latin1');
+ } else {
+ $encrypted = substr($encrypted_text, Crypto::$CIPHER_BLOCK_SIZE);
+ }
$decrypted = mdecrypt_generic($td, $encrypted);
/* Terminate decryption handle and close module */
mcrypt_generic_deinit($td);