From: <wis...@us...> - 2012-10-16 07:36:51
|
Revision: 10224 http://sourceforge.net/p/xoops/svn/10224 Author: wishcraft Date: 2012-10-16 07:36:36 +0000 (Tue, 16 Oct 2012) Log Message: ----------- XFriendica Class & Packages Design (Alpha) Modified Paths: -------------- XoopsModules/xfriendica/trunk/modules/xfriendica/class/hash/hash.php XoopsModules/xfriendica/trunk/modules/xfriendica/class/hash/md5/md5.php XoopsModules/xfriendica/trunk/modules/xfriendica/class/hash/password/password.php XoopsModules/xfriendica/trunk/modules/xfriendica/class/hash/sha1/sha1.php XoopsModules/xfriendica/trunk/modules/xfriendica/class/hash/xoopscrc/xoopscrc.php Added Paths: ----------- XoopsModules/xfriendica/trunk/modules/xfriendica/class/ciphers/ XoopsModules/xfriendica/trunk/modules/xfriendica/class/ciphers/ciphers.php XoopsModules/xfriendica/trunk/modules/xfriendica/class/ciphers/mcrypt/ XoopsModules/xfriendica/trunk/modules/xfriendica/class/ciphers/mcrypt/3des/ XoopsModules/xfriendica/trunk/modules/xfriendica/class/ciphers/mcrypt/3des/3des.php XoopsModules/xfriendica/trunk/modules/xfriendica/class/ciphers/mcrypt/crypt/ XoopsModules/xfriendica/trunk/modules/xfriendica/class/ciphers/mcrypt/crypt/crypt.php XoopsModules/xfriendica/trunk/modules/xfriendica/class/ciphers/mcrypt/mars/ XoopsModules/xfriendica/trunk/modules/xfriendica/class/ciphers/mcrypt/mars/mars.php XoopsModules/xfriendica/trunk/modules/xfriendica/class/ciphers/mcrypt/mcrypt.php XoopsModules/xfriendica/trunk/modules/xfriendica/class/ciphers/mcrypt/panama/ XoopsModules/xfriendica/trunk/modules/xfriendica/class/ciphers/mcrypt/panama/panama.php XoopsModules/xfriendica/trunk/modules/xfriendica/class/ciphers/mcrypt/rc2/ XoopsModules/xfriendica/trunk/modules/xfriendica/class/ciphers/mcrypt/rc2/rc2.php XoopsModules/xfriendica/trunk/modules/xfriendica/class/ciphers/mcrypt/rc4/ XoopsModules/xfriendica/trunk/modules/xfriendica/class/ciphers/mcrypt/rc4/rc4.php XoopsModules/xfriendica/trunk/modules/xfriendica/class/ciphers/mcrypt/rc6/ XoopsModules/xfriendica/trunk/modules/xfriendica/class/ciphers/mcrypt/rc6/rc6.php XoopsModules/xfriendica/trunk/modules/xfriendica/class/ciphers/mcrypt/safer128/ XoopsModules/xfriendica/trunk/modules/xfriendica/class/ciphers/mcrypt/safer128/safer128.php XoopsModules/xfriendica/trunk/modules/xfriendica/class/ciphers/mcrypt/safer64/ XoopsModules/xfriendica/trunk/modules/xfriendica/class/ciphers/mcrypt/safer64/safer64.php XoopsModules/xfriendica/trunk/modules/xfriendica/class/ciphers/mcrypt/saferplus/ XoopsModules/xfriendica/trunk/modules/xfriendica/class/ciphers/mcrypt/saferplus/saferplus.php XoopsModules/xfriendica/trunk/modules/xfriendica/class/ciphers/mcrypt/serpent/ XoopsModules/xfriendica/trunk/modules/xfriendica/class/ciphers/mcrypt/serpent/serpent.php XoopsModules/xfriendica/trunk/modules/xfriendica/class/ciphers/mcrypt/skipjack/ XoopsModules/xfriendica/trunk/modules/xfriendica/class/ciphers/mcrypt/skipjack/skipjack.php XoopsModules/xfriendica/trunk/modules/xfriendica/class/ciphers/mcrypt/threeway/ XoopsModules/xfriendica/trunk/modules/xfriendica/class/ciphers/mcrypt/threeway/threeway.php XoopsModules/xfriendica/trunk/modules/xfriendica/class/ciphers/mcrypt/tripledes/ XoopsModules/xfriendica/trunk/modules/xfriendica/class/ciphers/mcrypt/tripledes/tripledes.php XoopsModules/xfriendica/trunk/modules/xfriendica/class/ciphers/mcrypt/twofish/ XoopsModules/xfriendica/trunk/modules/xfriendica/class/ciphers/mcrypt/twofish/twofish.php XoopsModules/xfriendica/trunk/modules/xfriendica/class/ciphers/mcrypt/wake/ XoopsModules/xfriendica/trunk/modules/xfriendica/class/ciphers/mcrypt/wake/wake.php XoopsModules/xfriendica/trunk/modules/xfriendica/class/ciphers/mcrypt/xtea/ XoopsModules/xfriendica/trunk/modules/xfriendica/class/ciphers/mcrypt/xtea/xtea.php XoopsModules/xfriendica/trunk/modules/xfriendica/class/ciphers/openssl/ XoopsModules/xfriendica/trunk/modules/xfriendica/class/ciphers/openssl/certificates/ XoopsModules/xfriendica/trunk/modules/xfriendica/class/ciphers/openssl/certificates/certificates.php XoopsModules/xfriendica/trunk/modules/xfriendica/class/ciphers/openssl/certificates/generate.php XoopsModules/xfriendica/trunk/modules/xfriendica/class/ciphers/openssl/certificates/mount.php XoopsModules/xfriendica/trunk/modules/xfriendica/class/ciphers/openssl/certificates/private.php XoopsModules/xfriendica/trunk/modules/xfriendica/class/ciphers/openssl/certificates/public.php XoopsModules/xfriendica/trunk/modules/xfriendica/class/ciphers/openssl/openssl.php XoopsModules/xfriendica/trunk/modules/xfriendica/class/ciphers/php/ XoopsModules/xfriendica/trunk/modules/xfriendica/class/ciphers/php/aes/ XoopsModules/xfriendica/trunk/modules/xfriendica/class/ciphers/php/aes/aes.class.php XoopsModules/xfriendica/trunk/modules/xfriendica/class/ciphers/php/aes/aes.php XoopsModules/xfriendica/trunk/modules/xfriendica/class/ciphers/php/php.php XoopsModules/xfriendica/trunk/modules/xfriendica/class/hash/guid/ XoopsModules/xfriendica/trunk/modules/xfriendica/class/hash/guid/guid.php XoopsModules/xfriendica/trunk/modules/xfriendica/class/hash/guid/index.html XoopsModules/xfriendica/trunk/modules/xfriendica/class/hash/salt/ XoopsModules/xfriendica/trunk/modules/xfriendica/class/hash/salt/index.html XoopsModules/xfriendica/trunk/modules/xfriendica/class/hash/salt/salt.php XoopsModules/xfriendica/trunk/modules/xfriendica/class/packages/ XoopsModules/xfriendica/trunk/modules/xfriendica/class/packages/base64/ XoopsModules/xfriendica/trunk/modules/xfriendica/class/packages/base64/base64.php XoopsModules/xfriendica/trunk/modules/xfriendica/class/packages/json/ XoopsModules/xfriendica/trunk/modules/xfriendica/class/packages/json/json.php XoopsModules/xfriendica/trunk/modules/xfriendica/class/packages/packages.php XoopsModules/xfriendica/trunk/modules/xfriendica/class/packages/serial/ XoopsModules/xfriendica/trunk/modules/xfriendica/class/packages/serial/serial.php XoopsModules/xfriendica/trunk/modules/xfriendica/class/packages/url/ XoopsModules/xfriendica/trunk/modules/xfriendica/class/packages/url/url.php XoopsModules/xfriendica/trunk/modules/xfriendica/class/packages/xml/ XoopsModules/xfriendica/trunk/modules/xfriendica/class/packages/xml/xml.php XoopsModules/xfriendica/trunk/modules/xfriendica/class/transport/ XoopsModules/xfriendica/trunk/modules/xfriendica/class/transport/curl/ XoopsModules/xfriendica/trunk/modules/xfriendica/class/transport/soap/ XoopsModules/xfriendica/trunk/modules/xfriendica/class/transport/wget/ XoopsModules/xfriendica/trunk/modules/xfriendica/protocols/curl/ XoopsModules/xfriendica/trunk/modules/xfriendica/protocols/curl/curl.php XoopsModules/xfriendica/trunk/modules/xfriendica/protocols/curl/pull/ XoopsModules/xfriendica/trunk/modules/xfriendica/protocols/curl/pull/pull.php XoopsModules/xfriendica/trunk/modules/xfriendica/protocols/curl/push/ XoopsModules/xfriendica/trunk/modules/xfriendica/protocols/curl/push/push.php XoopsModules/xfriendica/trunk/modules/xfriendica/protocols/protocols.php XoopsModules/xfriendica/trunk/modules/xfriendica/protocols/rest/ XoopsModules/xfriendica/trunk/modules/xfriendica/protocols/rest/pull/ XoopsModules/xfriendica/trunk/modules/xfriendica/protocols/rest/pull/pull.php XoopsModules/xfriendica/trunk/modules/xfriendica/protocols/rest/push/ XoopsModules/xfriendica/trunk/modules/xfriendica/protocols/rest/push/push.php XoopsModules/xfriendica/trunk/modules/xfriendica/protocols/rest/rest.php XoopsModules/xfriendica/trunk/modules/xfriendica/protocols/soap/ XoopsModules/xfriendica/trunk/modules/xfriendica/protocols/soap/pull/ XoopsModules/xfriendica/trunk/modules/xfriendica/protocols/soap/pull/pull.php XoopsModules/xfriendica/trunk/modules/xfriendica/protocols/soap/push/ XoopsModules/xfriendica/trunk/modules/xfriendica/protocols/soap/push/push.php XoopsModules/xfriendica/trunk/modules/xfriendica/protocols/soap/soap.php XoopsModules/xfriendica/trunk/modules/xfriendica/protocols/wget/ XoopsModules/xfriendica/trunk/modules/xfriendica/protocols/wget/curl.php XoopsModules/xfriendica/trunk/modules/xfriendica/protocols/wget/pull/ XoopsModules/xfriendica/trunk/modules/xfriendica/protocols/wget/pull/pull.php XoopsModules/xfriendica/trunk/modules/xfriendica/protocols/wget/push/ XoopsModules/xfriendica/trunk/modules/xfriendica/protocols/wget/push/push.php XoopsModules/xfriendica/trunk/modules/xfriendica/protocols/xips/ XoopsModules/xfriendica/trunk/modules/xfriendica/protocols/xips/pull/ XoopsModules/xfriendica/trunk/modules/xfriendica/protocols/xips/pull/pull.php XoopsModules/xfriendica/trunk/modules/xfriendica/protocols/xips/push/ XoopsModules/xfriendica/trunk/modules/xfriendica/protocols/xips/push/push.php XoopsModules/xfriendica/trunk/modules/xfriendica/protocols/xips/xips.php XoopsModules/xfriendica/trunk/modules/xfriendica/protocols/xsnep/ XoopsModules/xfriendica/trunk/modules/xfriendica/protocols/xsnep/pull/ XoopsModules/xfriendica/trunk/modules/xfriendica/protocols/xsnep/pull/pull.php XoopsModules/xfriendica/trunk/modules/xfriendica/protocols/xsnep/push/ XoopsModules/xfriendica/trunk/modules/xfriendica/protocols/xsnep/push/push.php XoopsModules/xfriendica/trunk/modules/xfriendica/protocols/xsnep/xsnep.php Added: XoopsModules/xfriendica/trunk/modules/xfriendica/class/ciphers/ciphers.php =================================================================== --- XoopsModules/xfriendica/trunk/modules/xfriendica/class/ciphers/ciphers.php (rev 0) +++ XoopsModules/xfriendica/trunk/modules/xfriendica/class/ciphers/ciphers.php 2012-10-16 07:36:36 UTC (rev 10224) @@ -0,0 +1,208 @@ +<?php +/** + * XOOPS checksum handler + * + * You may not change or alter any portion of this comment or credits + * of supporting developers from this source code or any supporting source code + * which is considered copyrighted (c) material of the original comment or credit authors. + * This program 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. + * + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @package kernel + * @since 2.5.5 + * @author Simon Roberts (AKA wishcraft) http://www.chronolabs.com.au/ + * @version $Id: xoopshash.php 8066 2012-09-08 12:19:00Z wishcraft $ + */ + +/** + * A checksum Class for hashing data. + * + * @abstract + */ +class XFriendicaCiphers { + + // Child Checksum/Ciphers Storage + var $_class = array(); + + // Errors Storage Mechanism + var $_errors = array(); + + // Last Checksum Calculated + var $_data = ''; + + // Last Type Cipherses/Checksums Used + var $_type = 'php'; + + // Default Options for the Preset Cipherses/Checksums + var $_options = array( 'php' => array('algorithm'=>'aes'), + 'mcrypt' => array('algorithm'=>'tripledes'), + 'openssl' => array() + ); + + private static $_vars = array( 'class' => array(), + 'data' => '', + 'type' => 'php', + 'options' => array( 'php' => array('algorithm'=>'aes'), + 'mcrypt' => array('algorithm'=>'tripledes'), + 'openssl' => array()) + ); + + /** + * Constructor + * + * @param string $data + * @param string $type + * @param array $options + */ + function __construct() { + foreach($this->_options as $package => $options) { + $this->setType($package); + } + } + + /** + * function __call + * magic method for calling checksum types as a function + * + * ie. + * $objsCiphers = new XFriendicaCiphers(); // Instanciate the Object + * $objsCiphers->md5($data); // Returns MD5 Checksum + * $objsCiphers->sha1($data); // Returns SHA1 Checksum + * $objsCiphers->xoopscrc($data); // Returns XoopsCrc Checksum + * $objsCiphers->password($data); // Returns Password Checksum + * + * @param string $type + * @param array $args + */ + function __call($type, $args) { + $parts = array(); + foreach($this->_class as $type => $handler) { + if (substr($type, 0, strlen('encrypt_'))=='encrypt_') { + $parts = explode('_', $type); + } elseif (substr($type, 0, strlen('decrypt_'))=='decrypt_') { + $parts = explode('_', $type); + } + if (count($parts)==2 && method_exists($handler, $type)) { + return $handler->{$type}($args[0], $args[1]); + } + }; + } + + /** + * function __callStatic + * magic method for calling checksum statically as types in function + * + * ie. + * XFriendicaCiphers::md5($data); // Returns MD5 Checksum + * XFriendicaCiphers::sha1($data); // Returns SHA1 Checksum + * XFriendicaCiphers::xoopscrc($data); // Returns XoopsCrc Checksum + * XFriendicaCiphers::password($data); // Returns Password Checksum + * + * @param string $type + * @param array $args + */ + function __callStatic($type, $args) { + if (empty($args[1])&&isset(self::$_vars['options'][$type])) + $args[1] = self::$_vars['options'][$type]; + return self::calcStatic($args[0], $type, $args[1]); + } + + /** + * function calc + * For calculating a hash/checksum after class is instanciated + * + * @param string $data + * @param string $type + * @param array $options + */ + function encrypt($data, $salt = '', $type = 'php') { + if (isset($this->_class[$type])) { + $this->_type = $type; + } elseif ($this->setType($type)) { + $this->_type = $type; + } + if (is_object($this->_class[$type])) + return $this->_class[$type]->encrypt($data, $salt); + else + $this->_errors[] = 'Error: XFriendicaCiphers Class Not Set'; + return false; + } + + /** + * function calc + * For calculating a hash/checksum after class is instanciated + * + * @param string $data + * @param string $type + * @param array $options + */ + function decrypt($data, $salt = '', $type = 'php') { + if (isset($this->_class[$type])) { + $this->_type = $type; + } elseif ($this->setType($type)) { + $this->_type = $type; + } + if (is_object($this->_class[$type])) + return $this->_class[$type]->decrypt($data, $salt); + else + $this->_errors[] = 'Error: XFriendicaCiphers Class Not Set'; + return false; + } + + /** + * private function setType + * For load a child Class and instaniating it + * + * @param string $type + * @param string $data + * @param array $options + */ + private function setType($type) { + if (file_exists(dirname(__FILE__).DS.$type.DS.$type.'.php')) { + if (!class_exists('XFriendicaCiphers'.ucfirst($type))) + include_once(dirname(__FILE__).DS.$type.DS.$type.'.php'); + $class = 'XFriendicaCiphers'.ucfirst($type); + if (class_exists($class)) { + $this->_type = $type; + $this->_class[$type] = new $class($this); + return true; + } else { + $this->_errors[] = 'Error: XFriendicaCiphers Child Class Does not Exist - '.$class.' missing.'; + } + } else { + $this->_errors[] = 'Error: XFriendicaCiphers Child Class Definition File Does not Exist - '.DS.$type.DS.$type.'.php missing.'; + } + return false; + } + + /** + * private function setTypeStatic + * For using child class statically + * + * @param string $type + * @param string $data + * @param array $options + */ + private function setTypeStatic($type, $data, $options) { + if (file_exists(dirname(__FILE__).DS.$type.DS.$type.'.php')) { + include_once(dirname(__FILE__).DS.$type.DS.$type.'.php'); + $class = 'XFriendicaCiphers'.ucfirst($type).'Static'; + if (class_exists($class)) { + return new $class(null, 'static'); + } + } + return false; + } + + /** + * function getErrorsHtml + * Gets the Errors as HTML for xoops_error() Function + * + */ + function getErrorsHtml() { + return implode('<br/>', $this->_errors); + } +} \ No newline at end of file Added: XoopsModules/xfriendica/trunk/modules/xfriendica/class/ciphers/mcrypt/3des/3des.php =================================================================== --- XoopsModules/xfriendica/trunk/modules/xfriendica/class/ciphers/mcrypt/3des/3des.php (rev 0) +++ XoopsModules/xfriendica/trunk/modules/xfriendica/class/ciphers/mcrypt/3des/3des.php 2012-10-16 07:36:36 UTC (rev 10224) @@ -0,0 +1,158 @@ +<?php +/** + * XOOPS crypt checksum handler + * + * You may not change or alter any portion of this comment or credits + * of supporting developers from this source code or any supporting source code + * which is considered copyrighted (c) material of the original comment or credit authors. + * This program 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. + * + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @package kernel + * @since 2.5.5 + * @author Simon Roberts (AKA wishcraft) http://www.chronolabs.com.au/ + * @version $Id: crypt.php 8066 2012-09-08 12:19:00Z wishcraft $ + */ + + +/** + * A crypt checksum wrapper class for hashing data. + * + */ +class XFriendicaCiphersMCrypt3Des extends XFriendicaCiphers +{ + /** + * function name and class typecast + * + */ + var $_func = MCRYPT_3DES; + + /** + * method name for calculation of checksum + * + */ + var $_method = array( 'encrypt' => 'encrypt', + 'decrypt' => 'decrypt' + ); + + /** + * class name of this class + * + */ + var $_name = __CLASS__; + + /** + * parent object from XFriendicaCiphers ($this) + * + */ + var $_parent = ''; + + /** + * chipher object from XFriendicaCiphers ($this) + * + */ + var $_cipher = ''; + + /** + * chipher_iv object from XFriendicaCiphers ($this) + * + */ + var $_cipher_iv = ''; + + /** + * Constructor + * + * @param string $data + * @param string $salt + * @param object $parent + */ + function __construct($data, $salt, $parent, $mode = 'inhertit') { + if (function_exists('mcrypt_module_open')) { + $this->_cipher = mcrypt_module_open($this->_func); + $this->_cipher_iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($this->_cipher), MCRYPT_RAND); + + switch ($mode) { + default: + $this->_parent = $parent; + if (empty($salt)&&is_object($this->_parent)) + $salt = $this->_parent->_options[$this->_func]; + if (!empty($data)) + $this->_data = $this->{$this->_method['encrypt']}($data, $salt); + break; + case 'static': + return $this->{$this->_method['encrypt']}($data, $salt); + } + } else { + trigger_error('MCrypt PHP Extension not Loaded is Required for '.__CLASS__. '::'.__FUNCTION__.' in file '.__FILE__, E_ERROR); + } + } + + /** + * function cipher + * For Calculating an Checksum from Parent Class + * + * @param string $data + * @param string $salt + */ + function cipher($data, $salt) { + return $this->{$this->_method['encrypt']}($data, $salt); + } + + /** + * function decipher + * For Calculating an Checksum from Parent Class + * + * @param string $data + * @param string $salt + */ + function decipher($data, $salt) { + return $this->{$this->_method['decrypt']}($data, $salt); + } + + /** + * private function crypt + * For calculating an Encryption + * + * @param string $data + * @param string $salt + */ + private function encrypt($data, $salt) { + mcrypt_generic_init($this->_cipher, $salt, $this->_cipher_iv); + $encrypted_data = mcrypt_generic($this->_cipher, $data); + return $encrypted_data; + } + + /** + * private function decrypt + * For calculating an Decryption + * + * @param string $data + * @param string $salt + */ + private function decrypt($data, $salt) { + mcrypt_generic_init($this->_cipher, $salt, $this->_cipher_iv); + $decrypted_data = mdecrypt_generic($this->_cipher, $data); + return $decrypted_data; + } + + function __destruct() { + mcrypt_generic_deinit($this->_cipher); + mcrypt_module_close($this->_cipher); + } +} + +/** + * A 3Des MCrypt wrapper class for hashing data statically. + * + * @abstract + */ +class XFriendicaCiphersMCrypt3DesStatic extends XFriendicaCiphersMCrypt3Des +{ + function __construct($data, $salt, $parent, $mode = 'inhertit') { + return parent::__construct($data, $salt, $parent, 'static'); + } +} +?> \ No newline at end of file Added: XoopsModules/xfriendica/trunk/modules/xfriendica/class/ciphers/mcrypt/crypt/crypt.php =================================================================== --- XoopsModules/xfriendica/trunk/modules/xfriendica/class/ciphers/mcrypt/crypt/crypt.php (rev 0) +++ XoopsModules/xfriendica/trunk/modules/xfriendica/class/ciphers/mcrypt/crypt/crypt.php 2012-10-16 07:36:36 UTC (rev 10224) @@ -0,0 +1,158 @@ +<?php +/** + * XOOPS crypt checksum handler + * + * You may not change or alter any portion of this comment or credits + * of supporting developers from this source code or any supporting source code + * which is considered copyrighted (c) material of the original comment or credit authors. + * This program 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. + * + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @package kernel + * @since 2.5.5 + * @author Simon Roberts (AKA wishcraft) http://www.chronolabs.com.au/ + * @version $Id: crypt.php 8066 2012-09-08 12:19:00Z wishcraft $ + */ + + +/** + * A crypt checksum wrapper class for hashing data. + * + */ +class XFriendicaCiphersMCryptCrypt extends XFriendicaCiphers +{ + /** + * function name and class typecast + * + */ + var $_func = MCRYPT_CRYPT; + + /** + * method name for calculation of checksum + * + */ + var $_method = array( 'encrypt' => 'encrypt', + 'decrypt' => 'decrypt' + ); + + /** + * class name of this class + * + */ + var $_name = __CLASS__; + + /** + * parent object from XFriendicaCiphers ($this) + * + */ + var $_parent = ''; + + /** + * chipher object from XFriendicaCiphers ($this) + * + */ + var $_cipher = ''; + + /** + * chipher_iv object from XFriendicaCiphers ($this) + * + */ + var $_cipher_iv = ''; + + /** + * Constructor + * + * @param string $data + * @param string $salt + * @param object $parent + */ + function __construct($data, $salt, $parent, $mode = 'inhertit') { + if (function_exists('mcrypt_module_open')) { + $this->_cipher = mcrypt_module_open($this->_func); + $this->_cipher_iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($this->_cipher), MCRYPT_RAND); + + switch ($mode) { + default: + $this->_parent = $parent; + if (empty($salt)&&is_object($this->_parent)) + $salt = $this->_parent->_options[$this->_func]; + if (!empty($data)) + $this->_data = $this->{$this->_method['encrypt']}($data, $salt); + break; + case 'static': + return $this->{$this->_method['encrypt']}($data, $salt); + } + } else { + trigger_error('MCrypt PHP Extension not Loaded is Required for '.__CLASS__. '::'.__FUNCTION__.' in file '.__FILE__, E_ERROR); + } + } + + /** + * function cipher + * For Calculating an Checksum from Parent Class + * + * @param string $data + * @param string $salt + */ + function cipher($data, $salt) { + return $this->{$this->_method['encrypt']}($data, $salt); + } + + /** + * function decipher + * For Calculating an Checksum from Parent Class + * + * @param string $data + * @param string $salt + */ + function decipher($data, $salt) { + return $this->{$this->_method['decrypt']}($data, $salt); + } + + /** + * private function crypt + * For calculating an Encryption + * + * @param string $data + * @param string $salt + */ + private function encrypt($data, $salt) { + mcrypt_generic_init($this->_cipher, $salt, $this->_cipher_iv); + $encrypted_data = mcrypt_generic($this->_cipher, $data); + return $encrypted_data; + } + + /** + * private function decrypt + * For calculating an Decryption + * + * @param string $data + * @param string $salt + */ + private function decrypt($data, $salt) { + mcrypt_generic_init($this->_cipher, $salt, $this->_cipher_iv); + $decrypted_data = mdecrypt_generic($this->_cipher, $data); + return $decrypted_data; + } + + function __destruct() { + mcrypt_generic_deinit($this->_cipher); + mcrypt_module_close($this->_cipher); + } +} + +/** + * A Crypt MCrypt wrapper class for hashing data statically. + * + * @abstract + */ +class XFriendicaCiphersMCryptCryptStatic extends XFriendicaCiphersMCryptCrypt +{ + function __construct($data, $salt, $parent, $mode = 'inhertit') { + return parent::__construct($data, $salt, $parent, 'static'); + } +} +?> \ No newline at end of file Added: XoopsModules/xfriendica/trunk/modules/xfriendica/class/ciphers/mcrypt/mars/mars.php =================================================================== --- XoopsModules/xfriendica/trunk/modules/xfriendica/class/ciphers/mcrypt/mars/mars.php (rev 0) +++ XoopsModules/xfriendica/trunk/modules/xfriendica/class/ciphers/mcrypt/mars/mars.php 2012-10-16 07:36:36 UTC (rev 10224) @@ -0,0 +1,158 @@ +<?php +/** + * XOOPS crypt checksum handler + * + * You may not change or alter any portion of this comment or credits + * of supporting developers from this source code or any supporting source code + * which is considered copyrighted (c) material of the original comment or credit authors. + * This program 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. + * + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @package kernel + * @since 2.5.5 + * @author Simon Roberts (AKA wishcraft) http://www.chronolabs.com.au/ + * @version $Id: crypt.php 8066 2012-09-08 12:19:00Z wishcraft $ + */ + + +/** + * A crypt checksum wrapper class for hashing data. + * + */ +class XFriendicaCiphersMCryptMars extends XFriendicaCiphers +{ + /** + * function name and class typecast + * + */ + var $_func = MCRYPT_MARS; + + /** + * method name for calculation of checksum + * + */ + var $_method = array( 'encrypt' => 'encrypt', + 'decrypt' => 'decrypt' + ); + + /** + * class name of this class + * + */ + var $_name = __CLASS__; + + /** + * parent object from XFriendicaCiphers ($this) + * + */ + var $_parent = ''; + + /** + * chipher object from XFriendicaCiphers ($this) + * + */ + var $_cipher = ''; + + /** + * chipher_iv object from XFriendicaCiphers ($this) + * + */ + var $_cipher_iv = ''; + + /** + * Constructor + * + * @param string $data + * @param string $salt + * @param object $parent + */ + function __construct($data, $salt, $parent, $mode = 'inhertit') { + if (function_exists('mcrypt_module_open')) { + $this->_cipher = mcrypt_module_open($this->_func); + $this->_cipher_iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($this->_cipher), MCRYPT_RAND); + + switch ($mode) { + default: + $this->_parent = $parent; + if (empty($salt)&&is_object($this->_parent)) + $salt = $this->_parent->_options[$this->_func]; + if (!empty($data)) + $this->_data = $this->{$this->_method['encrypt']}($data, $salt); + break; + case 'static': + return $this->{$this->_method['encrypt']}($data, $salt); + } + } else { + trigger_error('MCrypt PHP Extension not Loaded is Required for '.__CLASS__. '::'.__FUNCTION__.' in file '.__FILE__, E_ERROR); + } + } + + /** + * function cipher + * For Calculating an Checksum from Parent Class + * + * @param string $data + * @param string $salt + */ + function cipher($data, $salt) { + return $this->{$this->_method['encrypt']}($data, $salt); + } + + /** + * function decipher + * For Calculating an Checksum from Parent Class + * + * @param string $data + * @param string $salt + */ + function decipher($data, $salt) { + return $this->{$this->_method['decrypt']}($data, $salt); + } + + /** + * private function crypt + * For calculating an Encryption + * + * @param string $data + * @param string $salt + */ + private function encrypt($data, $salt) { + mcrypt_generic_init($this->_cipher, $salt, $this->_cipher_iv); + $encrypted_data = mcrypt_generic($this->_cipher, $data); + return $encrypted_data; + } + + /** + * private function decrypt + * For calculating an Decryption + * + * @param string $data + * @param string $salt + */ + private function decrypt($data, $salt) { + mcrypt_generic_init($this->_cipher, $salt, $this->_cipher_iv); + $decrypted_data = mdecrypt_generic($this->_cipher, $data); + return $decrypted_data; + } + + function __destruct() { + mcrypt_generic_deinit($this->_cipher); + mcrypt_module_close($this->_cipher); + } +} + +/** + * A Crypt MCrypt wrapper class for hashing data statically. + * + * @abstract + */ +class XFriendicaCiphersMCryptMarsStatic extends XFriendicaCiphersMCryptMars +{ + function __construct($data, $salt, $parent, $mode = 'inhertit') { + return parent::__construct($data, $salt, $parent, 'static'); + } +} +?> \ No newline at end of file Added: XoopsModules/xfriendica/trunk/modules/xfriendica/class/ciphers/mcrypt/mcrypt.php =================================================================== --- XoopsModules/xfriendica/trunk/modules/xfriendica/class/ciphers/mcrypt/mcrypt.php (rev 0) +++ XoopsModules/xfriendica/trunk/modules/xfriendica/class/ciphers/mcrypt/mcrypt.php 2012-10-16 07:36:36 UTC (rev 10224) @@ -0,0 +1,189 @@ +<?php +/** + * XOOPS crypt checksum handler + * + * You may not change or alter any portion of this comment or credits + * of supporting developers from this source code or any supporting source code + * which is considered copyrighted (c) material of the original comment or credit authors. + * This program 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. + * + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @package kernel + * @since 2.5.5 + * @author Simon Roberts (AKA wishcraft) http://www.chronolabs.com.au/ + * @version $Id: crypt.php 8066 2012-09-08 12:19:00Z wishcraft $ + */ + + +/** + * A crypt checksum wrapper class for hashing data. + * + */ +class XFriendicaCipherMcrypt extends XFriendicaCipher +{ + /** + * function name and class typecast + * + */ + var $_preferences = array( 0 => 'tripledes', + 1 => '3des', + 2 => 'threeway', + 3 => 'twofish', + 4 => 'mars', + 5 => 'panama', + 6 => 'serpent', + 7 => 'crypt', + 8 => 'rc2', + 9 => 'rc4', + 10 => 'rc6', + 11 => 'saferplus', + 12 => 'safer128', + 13 => 'safer64', + 14 => 'slipjack', + 15 => 'wake', + 16 => 'xtea' + ); + + /** + * method name for calculation of checksum + * + */ + var $_method = array( 'encrypt' => 'encrypt', + 'decrypt' => 'decrypt' + ); + + /** + * class name of this class + * + */ + var $_name = __CLASS__; + + /** + * parent object from XFriendicaCipher ($this) + * + */ + var $_parent = ''; + + + /** + * algorithm for MCrypt from XFriendicaCipher ($this) + * + */ + var $_algorithm = ''; + + /** + * algorithms Objects for MCrypt from XFriendicaCipher ($this) + * + */ + var $_algorithms = array(); + + /** + * Constructor + * + * @param string $data + * @param string $salt + * @param object $parent + */ + function __construct($data, $options, $parent, $mode = 'inhertit') { + if (function_exists('mcrypt_list_algorithms')) { + foreach(mcrypt_list_algorithms() as $algorithm) { + if (empty($this->_algorithm)) { + if ($algorithm == $options['algorithm']) { + $this->_algorithm = $options['algorithm']; + } + if (in_array($algorithm, $this->_preferences)) { + $this->_algorithm = $algorithm; + } + } + } + @loadAlgorithm($this->_algorithm); + } + } + + function getAlgorithms() { + return $_preferences; + } + + /** + * private function loadAlgorithm + * For Loading an Algorithm Child Class + * + * @param string $dirname + */ + private function loadAlgorithm($dirname) { + if (!in_array($dirname, mcrypt_list_algorithms())) { + trigger_error('MCrypt Algorithm '. $dirname. ' doesn\'t exist in '.__CLASS__.'::'.__FUNCTION__. ' in file '.__FILE__, E_ERROR); + return false; + } + if (!isset($this->_algorithms[$dirname])) { + include_once dirname(__FILE__).DS.$dirname.DS.$dirname.'.php'; + $class = 'XFriendicaCipherMCrypt'.ucfirst($dirname); + $this->_algorithms[$dirname] = new $class('', '', $this, 'inherit'); + } + return true; + } + + + function __call($type, $args) { + $parts = array(); + if (substr($type, 0, strlen('encrypt_'))=='encrypt_') { + $parts = explode('_', $type); + if (!in_array($parts[1], $this->_preferences)) { + return false; + } + } elseif (substr($type, 0, strlen('decrypt_'))=='decrypt_') { + $parts = explode('_', $type); + if (!in_array($parts[1], $this->_preferences)) { + return false; + } + } + if (count($parts)==2&&loadAlgorithm($parts[1])==true) { + switch ($parts[0]) { + case 'encrypt': + return $this->_algorithms[$parts[0]]->cipher($args[0], $args[1]); + break; + case 'decrypt': + return $this->_algorithms[$parts[0]]->decipher($args[0], $args[1]); + break; + } + } + } + /** + * function cipher + * For Calculating an Checksum from Parent Class + * + * @param string $data + * @param string $salt + */ + function cipher($data, $salt) { + return $this->_algorithms[$this->_algorithm]->cipher($data, $salt); + } + + /** + * function decipher + * For Calculating an Checksum from Parent Class + * + * @param string $data + * @param string $salt + */ + function decipher($data, $salt) { + return $this->_algorithms[$this->_algorithm]->decipher($data, $salt); + } + +} + +/** + * A md5 checksum wrapper class for hashing data statically. + * + * @abstract + */ +class XFriendicaCipherMcryptStatic extends XFriendicaCipherMcrypt +{ + function __construct($data, $options, $parent, $mode = 'inhertit') { + return parent::__construct($data, $options, $parent, 'static'); + } +} +?> \ No newline at end of file Added: XoopsModules/xfriendica/trunk/modules/xfriendica/class/ciphers/mcrypt/panama/panama.php =================================================================== --- XoopsModules/xfriendica/trunk/modules/xfriendica/class/ciphers/mcrypt/panama/panama.php (rev 0) +++ XoopsModules/xfriendica/trunk/modules/xfriendica/class/ciphers/mcrypt/panama/panama.php 2012-10-16 07:36:36 UTC (rev 10224) @@ -0,0 +1,158 @@ +<?php +/** + * XOOPS crypt checksum handler + * + * You may not change or alter any portion of this comment or credits + * of supporting developers from this source code or any supporting source code + * which is considered copyrighted (c) material of the original comment or credit authors. + * This program 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. + * + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @package kernel + * @since 2.5.5 + * @author Simon Roberts (AKA wishcraft) http://www.chronolabs.com.au/ + * @version $Id: crypt.php 8066 2012-09-08 12:19:00Z wishcraft $ + */ + + +/** + * A crypt checksum wrapper class for hashing data. + * + */ +class XFriendicaCiphersMCryptPanama extends XFriendicaCiphers +{ + /** + * function name and class typecast + * + */ + var $_func = MCRYPT_PANAMA; + + /** + * method name for calculation of checksum + * + */ + var $_method = array( 'encrypt' => 'encrypt', + 'decrypt' => 'decrypt' + ); + + /** + * class name of this class + * + */ + var $_name = __CLASS__; + + /** + * parent object from XFriendicaCiphers ($this) + * + */ + var $_parent = ''; + + /** + * chipher object from XFriendicaCiphers ($this) + * + */ + var $_cipher = ''; + + /** + * chipher_iv object from XFriendicaCiphers ($this) + * + */ + var $_cipher_iv = ''; + + /** + * Constructor + * + * @param string $data + * @param string $salt + * @param object $parent + */ + function __construct($data, $salt, $parent, $mode = 'inhertit') { + if (function_exists('mcrypt_module_open')) { + $this->_cipher = mcrypt_module_open($this->_func); + $this->_cipher_iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($this->_cipher), MCRYPT_RAND); + + switch ($mode) { + default: + $this->_parent = $parent; + if (empty($salt)&&is_object($this->_parent)) + $salt = $this->_parent->_options[$this->_func]; + if (!empty($data)) + $this->_data = $this->{$this->_method['encrypt']}($data, $salt); + break; + case 'static': + return $this->{$this->_method['encrypt']}($data, $salt); + } + } else { + trigger_error('MCrypt PHP Extension not Loaded is Required for '.__CLASS__. '::'.__FUNCTION__.' in file '.__FILE__, E_ERROR); + } + } + + /** + * function cipher + * For Calculating an Checksum from Parent Class + * + * @param string $data + * @param string $salt + */ + function cipher($data, $salt) { + return $this->{$this->_method['encrypt']}($data, $salt); + } + + /** + * function decipher + * For Calculating an Checksum from Parent Class + * + * @param string $data + * @param string $salt + */ + function decipher($data, $salt) { + return $this->{$this->_method['decrypt']}($data, $salt); + } + + /** + * private function crypt + * For calculating an Encryption + * + * @param string $data + * @param string $salt + */ + private function encrypt($data, $salt) { + mcrypt_generic_init($this->_cipher, $salt, $this->_cipher_iv); + $encrypted_data = mcrypt_generic($this->_cipher, $data); + return $encrypted_data; + } + + /** + * private function decrypt + * For calculating an Decryption + * + * @param string $data + * @param string $salt + */ + private function decrypt($data, $salt) { + mcrypt_generic_init($this->_cipher, $salt, $this->_cipher_iv); + $decrypted_data = mdecrypt_generic($this->_cipher, $data); + return $decrypted_data; + } + + function __destruct() { + mcrypt_generic_deinit($this->_cipher); + mcrypt_module_close($this->_cipher); + } +} + +/** + * A Crypt MCrypt wrapper class for hashing data statically. + * + * @abstract + */ +class XFriendicaCiphersMCryptPanamaStatic extends XFriendicaCiphersMCryptPanama +{ + function __construct($data, $salt, $parent, $mode = 'inhertit') { + return parent::__construct($data, $salt, $parent, 'static'); + } +} +?> \ No newline at end of file Added: XoopsModules/xfriendica/trunk/modules/xfriendica/class/ciphers/mcrypt/rc2/rc2.php =================================================================== --- XoopsModules/xfriendica/trunk/modules/xfriendica/class/ciphers/mcrypt/rc2/rc2.php (rev 0) +++ XoopsModules/xfriendica/trunk/modules/xfriendica/class/ciphers/mcrypt/rc2/rc2.php 2012-10-16 07:36:36 UTC (rev 10224) @@ -0,0 +1,158 @@ +<?php +/** + * XOOPS crypt checksum handler + * + * You may not change or alter any portion of this comment or credits + * of supporting developers from this source code or any supporting source code + * which is considered copyrighted (c) material of the original comment or credit authors. + * This program 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. + * + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @package kernel + * @since 2.5.5 + * @author Simon Roberts (AKA wishcraft) http://www.chronolabs.com.au/ + * @version $Id: crypt.php 8066 2012-09-08 12:19:00Z wishcraft $ + */ + + +/** + * A crypt checksum wrapper class for hashing data. + * + */ +class XFriendicaCiphersMCryptRc2 extends XFriendicaCiphers +{ + /** + * function name and class typecast + * + */ + var $_func = MCRYPT_RC2; + + /** + * method name for calculation of checksum + * + */ + var $_method = array( 'encrypt' => 'encrypt', + 'decrypt' => 'decrypt' + ); + + /** + * class name of this class + * + */ + var $_name = __CLASS__; + + /** + * parent object from XFriendicaCiphers ($this) + * + */ + var $_parent = ''; + + /** + * chipher object from XFriendicaCiphers ($this) + * + */ + var $_cipher = ''; + + /** + * chipher_iv object from XFriendicaCiphers ($this) + * + */ + var $_cipher_iv = ''; + + /** + * Constructor + * + * @param string $data + * @param string $salt + * @param object $parent + */ + function __construct($data, $salt, $parent, $mode = 'inhertit') { + if (function_exists('mcrypt_module_open')) { + $this->_cipher = mcrypt_module_open($this->_func); + $this->_cipher_iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($this->_cipher), MCRYPT_RAND); + + switch ($mode) { + default: + $this->_parent = $parent; + if (empty($salt)&&is_object($this->_parent)) + $salt = $this->_parent->_options[$this->_func]; + if (!empty($data)) + $this->_data = $this->{$this->_method['encrypt']}($data, $salt); + break; + case 'static': + return $this->{$this->_method['encrypt']}($data, $salt); + } + } else { + trigger_error('MCrypt PHP Extension not Loaded is Required for '.__CLASS__. '::'.__FUNCTION__.' in file '.__FILE__, E_ERROR); + } + } + + /** + * function cipher + * For Calculating an Checksum from Parent Class + * + * @param string $data + * @param string $salt + */ + function cipher($data, $salt) { + return $this->{$this->_method['encrypt']}($data, $salt); + } + + /** + * function decipher + * For Calculating an Checksum from Parent Class + * + * @param string $data + * @param string $salt + */ + function decipher($data, $salt) { + return $this->{$this->_method['decrypt']}($data, $salt); + } + + /** + * private function crypt + * For calculating an Encryption + * + * @param string $data + * @param string $salt + */ + private function encrypt($data, $salt) { + mcrypt_generic_init($this->_cipher, $salt, $this->_cipher_iv); + $encrypted_data = mcrypt_generic($this->_cipher, $data); + return $encrypted_data; + } + + /** + * private function decrypt + * For calculating an Decryption + * + * @param string $data + * @param string $salt + */ + private function decrypt($data, $salt) { + mcrypt_generic_init($this->_cipher, $salt, $this->_cipher_iv); + $decrypted_data = mdecrypt_generic($this->_cipher, $data); + return $decrypted_data; + } + + function __destruct() { + mcrypt_generic_deinit($this->_cipher); + mcrypt_module_close($this->_cipher); + } +} + +/** + * A Crypt MCrypt wrapper class for hashing data statically. + * + * @abstract + */ +class XFriendicaCiphersMCryptRc2Static extends XFriendicaCiphersMCryptRc2 +{ + function __construct($data, $salt, $parent, $mode = 'inhertit') { + return parent::__construct($data, $salt, $parent, 'static'); + } +} +?> \ No newline at end of file Added: XoopsModules/xfriendica/trunk/modules/xfriendica/class/ciphers/mcrypt/rc4/rc4.php =================================================================== --- XoopsModules/xfriendica/trunk/modules/xfriendica/class/ciphers/mcrypt/rc4/rc4.php (rev 0) +++ XoopsModules/xfriendica/trunk/modules/xfriendica/class/ciphers/mcrypt/rc4/rc4.php 2012-10-16 07:36:36 UTC (rev 10224) @@ -0,0 +1,158 @@ +<?php +/** + * XOOPS crypt checksum handler + * + * You may not change or alter any portion of this comment or credits + * of supporting developers from this source code or any supporting source code + * which is considered copyrighted (c) material of the original comment or credit authors. + * This program 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. + * + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @package kernel + * @since 2.5.5 + * @author Simon Roberts (AKA wishcraft) http://www.chronolabs.com.au/ + * @version $Id: crypt.php 8066 2012-09-08 12:19:00Z wishcraft $ + */ + + +/** + * A crypt checksum wrapper class for hashing data. + * + */ +class XFriendicaCiphersMCryptRc4 extends XFriendicaCiphers +{ + /** + * function name and class typecast + * + */ + var $_func = MCRYPT_RC4; + + /** + * method name for calculation of checksum + * + */ + var $_method = array( 'encrypt' => 'encrypt', + 'decrypt' => 'decrypt' + ); + + /** + * class name of this class + * + */ + var $_name = __CLASS__; + + /** + * parent object from XFriendicaCiphers ($this) + * + */ + var $_parent = ''; + + /** + * chipher object from XFriendicaCiphers ($this) + * + */ + var $_cipher = ''; + + /** + * chipher_iv object from XFriendicaCiphers ($this) + * + */ + var $_cipher_iv = ''; + + /** + * Constructor + * + * @param string $data + * @param string $salt + * @param object $parent + */ + function __construct($data, $salt, $parent, $mode = 'inhertit') { + if (function_exists('mcrypt_module_open')) { + $this->_cipher = mcrypt_module_open($this->_func); + $this->_cipher_iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($this->_cipher), MCRYPT_RAND); + + switch ($mode) { + default: + $this->_parent = $parent; + if (empty($salt)&&is_object($this->_parent)) + $salt = $this->_parent->_options[$this->_func]; + if (!empty($data)) + $this->_data = $this->{$this->_method['encrypt']}($data, $salt); + break; + case 'static': + return $this->{$this->_method['encrypt']}($data, $salt); + } + } else { + trigger_error('MCrypt PHP Extension not Loaded is Required for '.__CLASS__. '::'.__FUNCTION__.' in file '.__FILE__, E_ERROR); + } + } + + /** + * function cipher + * For Calculating an Checksum from Parent Class + * + * @param string $data + * @param string $salt + */ + function cipher($data, $salt) { + return $this->{$this->_method['encrypt']}($data, $salt); + } + + /** + * function decipher + * For Calculating an Checksum from Parent Class + * + * @param string $data + * @param string $salt + */ + function decipher($data, $salt) { + return $this->{$this->_method['decrypt']}($data, $salt); + } + + /** + * private function crypt + * For calculating an Encryption + * + * @param string $data + * @param string $salt + */ + private function encrypt($data, $salt) { + mcrypt_generic_init($this->_cipher, $salt, $this->_cipher_iv); + $encrypted_data = mcrypt_generic($this->_cipher, $data); + return $encrypted_data; + } + + /** + * private function decrypt + * For calculating an Decryption + * + * @param string $data + * @param string $salt + */ + private function decrypt($data, $salt) { + mcrypt_generic_init($this->_cipher, $salt, $this->_cipher_iv); + $decrypted_data = mdecrypt_generic($this->_cipher, $data); + return $decrypted_data; + } + + function __destruct() { + mcrypt_generic_deinit($this->_cipher); + mcrypt_module_close($this->_cipher); + } +} + +/** + * A Crypt MCrypt wrapper class for hashing data statically. + * + * @abstract + */ +class XFriendicaCiphersMCryptRc4Static extends XFriendicaCiphersMCryptRc4 +{ + function __construct($data, $salt, $parent, $mode = 'inhertit') { + return parent::__construct($data, $salt, $parent, 'static'); + } +} +?> \ No newline at end of file Added: XoopsModules/xfriendica/trunk/modules/xfriendica/class/ciphers/mcrypt/rc6/rc6.php =================================================================== --- XoopsModules/xfriendica/trunk/modules/xfriendica/class/ciphers/mcrypt/rc6/rc6.php (rev 0) +++ XoopsModules/xfriendica/trunk/modules/xfriendica/class/ciphers/mcrypt/rc6/rc6.php 2012-10-16 07:36:36 UTC (rev 10224) @@ -0,0 +1,158 @@ +<?php +/** + * XOOPS crypt checksum handler + * + * You may not change or alter any portion of this comment or credits + * of supporting developers from this source code or any supporting source code + * which is considered copyrighted (c) material of the original comment or credit authors. + * This program 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. + * + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @package kernel + * @since 2.5.5 + * @author Simon Roberts (AKA wishcraft) http://www.chronolabs.com.au/ + * @version $Id: crypt.php 8066 2012-09-08 12:19:00Z wishcraft $ + */ + + +/** + * A crypt checksum wrapper class for hashing data. + * + */ +class XFriendicaCiphersMCryptRc6 extends XFriendicaCiphers +{ + /** + * function name and class typecast + * + */ + var $_func = MCRYPT_RC6; + + /** + * method name for calculation of checksum + * + */ + var $_method = array( 'encrypt' => 'encrypt', + 'decrypt' => 'decrypt' + ); + + /** + * class name of this class + * + */ + var $_name = __CLASS__; + + /** + * parent object from XFriendicaCiphers ($this) + * + */ + var $_parent = ''; + + /** + * chipher object from XFriendicaCiphers ($this) + * + */ + var $_cipher = ''; + + /** + * chipher_iv object from XFriendicaCiphers ($this) + * + */ + var $_cipher_iv = ''; + + /** + * Constructor + * + * @param string $data + * @param string $salt + * @param object $parent + */ + function __construct($data, $salt, $parent, $mode = 'inhertit') { + if (function_exists('mcrypt_module_open')) { + $this->_cipher = mcrypt_module_open($this->_func); + $this->_cipher_iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($this->_cipher), MCRYPT_RAND); + + switch ($mode) { + default: + $this->_parent = $parent; + if (empty($salt)&&is_object($this->_parent)) + $salt = $this->_parent->_options[$this->_func]; + if (!empty($data)) + $this->_data = $this->{$this->_method['encrypt']}($data, $salt); + break; + case 'static': + return $this->{$this->_method['encrypt']}($data, $salt); + } + } else { + trigger_error('MCrypt PHP Extension not Loaded is Required for '.__CLASS__. '::'.__FUNCTION__.' in file '.__FILE__, E_ERROR); + } + } + + /** + * function cipher + * For Calculating an Checksum from Parent Class + * + * @param string $data + * @param string $salt + */ + function cipher($data, $salt) { + return $this->{$this->_method['encrypt']}($data, $salt); + } + + /** + * function decipher + * For Calculating an Checksum from Parent Class + * + * @param string $data + * @param string $salt + */ + function decipher($data, $salt) { + return $this->{$this->_method['decrypt']}($data, $salt); + } + + /** + * private function crypt + * For calculating an Encryption + * + * @param string $data + * @param string $salt + */ + private function encrypt($data, $salt) { + mcrypt_generic_init($this->_cipher, $salt, $this->_cipher_iv); + $encrypted_data = mcrypt_generic($this->_cipher, $data); + return $encrypted_data; + } + + /** + * private function decrypt + * For calculating an Decryption + * + * @param string $data + * @param string $salt + */ + private function decrypt($data, $salt) { + mcrypt_generic_init($this->_cipher, $salt, $this->_cipher_iv); + $decrypted_data = mdecrypt_generic($this->_cipher, $data); + return $decrypted_data; + } + + function __destruct() { + mcrypt_generic_deinit($this->_cipher); + mcrypt_module_close($this->_cipher); + } +} + +/** + * A Crypt MCrypt wrapper class for hashing data statically. + * + * @abstract + */ +class XFriendicaCiphersMCryptRc6Static extends XFriendicaCiphersMCryptRc6 +{ + function __construct($data, $salt, $parent, $mode = 'inhertit') { + return parent::__construct($data, $salt, $parent, 'static'); + } +} +?> \ No newline at end of file Added: XoopsModules/xfriendica/trunk/modules/xfriendica/class/ciphers/mcrypt/safer128/safer128.php =================================================================== --- XoopsModules/xfriendica/trunk/modules/xfriendica/class/ciphers/mcrypt/safer128/safer128.php (rev 0) +++ XoopsModules/xfriendica/trunk/modules/xfriendica/class/ciphers/mcrypt/safer128/safer128.php 2012-10-16 07:36:36 UTC (rev 10224) @@ -0,0 +1,158 @@ +<?php +/** + * XOOPS crypt checksum handler + * + * You may not change or alter any portion of this comment or credits + * of supporting developers from this source code or any supporting source code + * which is considered copyrighted (c) material of the original comment or credit authors. + * This program 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. + * + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @package kernel + * @since 2.5.5 + * @author Simon Roberts (AKA wishcraft) http://www.chronolabs.com.au/ + * @version $Id: crypt.php 8066 2012-09-08 12:19:00Z wishcraft $ + */ + + +/** + * A crypt checksum wrapper class for hashing data. + * + */ +class XFriendicaCiphersMCryptSafer128 extends XFriendicaCiphers +{ + /** + * function name and class typecast + * + */ + var $_func = MCRYPT_SAFER128; + + /** + * method name for calculation of checksum + * + */ + var $_method = array( 'encrypt' => 'encrypt', + 'decrypt' => 'decrypt' + ); + + /** + * class name of this class + * + */ + var $_name = __CLASS__; + + /** + * parent object from XFriendicaCiphers ($this) + * + */ + var $_parent = ''; + + /** + * chipher object from XFriendicaCiphers ($this) + * + */ + var $_cipher = ''; + + /** + * chipher_iv object from XFriendicaCiphers ($this) + * + */ + var $_cipher_iv = ''; + + /** + * Constructor + * + * @param string $data + * @param string $salt + * @param object $parent + */ + function __construct($data, $salt, $parent, $mode = 'inhertit') { + if (function_exists('mcrypt_module_open')) { + $this->_cipher = mcrypt_module_open($this->_func); + $this->_cipher_iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($this->_cipher), MCRYPT_RAND); + + switch ($mode) { + default: + $this->_parent = $parent; + if (empty($salt)&&is_object($this->_parent)) + $salt = $this->_parent->_options[$this->_func]; + if (!empty($data)) + $this->_data = $this->{$this->_method['encrypt']}($data, $salt); + break; + case 'static': + return $this->{$this->_method['encrypt']}($data, $salt); + } + } else { + trigger_error('MCrypt PHP Extension not Loaded is Required for '.__CLASS__. '::'.__FUNCTION__.' in file '.__FILE__, E_ERROR); + } + } + + /** + * function cipher + * For Calculating an Checksum from Parent Class + * + * @param string $data + * @param string $salt + */ + function cipher($data, $salt) { + return $this->{$this->_method['encrypt']}($data, $salt); + } + + /** + * function decipher + * For Calculating an Checksum from Parent Class + * + * @param string $data + * @param string $salt + */ + function decipher($data, $salt) { + return $this->{$this->_method['decrypt']}($data, $salt); + } + + /** + * private function crypt + * For calculating an Encryption + * + * @param string $data + * @param string $salt + */ + private function encrypt($data, $salt) { + mcrypt_generic_init($this->_cipher, $salt, $this->_cipher_iv); + $encrypted_data = mcrypt_generic($this->_cipher, $data); + return $encrypted_data; + } + + /** + * private function decrypt + * For calculating an Decryption + * + * @param string $data + * @param string $salt + */ + private function decrypt($data, $salt) { + mcrypt_generic_init($this->_cipher, $salt, $this->_cipher_iv); + $decrypted_data = mdecrypt_generic($this->_cipher, $data); + return $decrypted_data; + } + + function __destruct() { + mcrypt_generic_deinit($this->_cipher); + mcrypt_module_close($this->_cipher); + } +} + +/** + * A Crypt MCrypt wrapper class for hashing data statically. + * + * @abstract + */ +class XFriendicaCiphersMCryptSafer128Static extends XFriendicaCiphersMCryptSafer128 +{ + function __construct($data, $salt, $parent, $mode = 'inhertit') { + return parent::__construct($data, $salt, $parent, 'static'); + } +} +?> \ No newline at end of file Added: XoopsModules/xfriendica/trunk/modules/xfriendica/class/ciphers/mcrypt/safer64/safer64.php =================================================================== --- XoopsModules/xfriendica/trunk/modules/xfriendica/class/ciphers/mcrypt/safer64/safer64.php (rev 0) +++ XoopsModules/xfriendica/trunk/modules/xfriendica/class/ciphers/mcrypt/safer64/safer64.php 2012-10-16 07:36:36 UTC (rev 10224) @@ -0,0 +1,158 @@ +<?php +/** + * XOOPS crypt checksum handler + * + * You may not change or alter any portion of this comment or credits + * of supporting developers from this source code or any supporting source code + * which is considered copyrighted (c) material of the original comment or credit authors. + * This program 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. + * + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @package kernel + * @since 2.5.5 + * @author Simon Roberts (AKA wishcraft) http://www.chronolabs.com.au/ + * @version $Id: crypt.php 8066 2012-09-08 12:19:00Z wishcraft $ + */ + + +/** + * A crypt checksum wrapper class for hashing data. + * + */ +class XFriendicaCiphersMCryptSafer64 extends XFriendicaCiphers +{ + /** + * function name and class typecast + * + */ + var $_func = MCRYPT_SAFER64; + + /** + * method name for calculation of checksum + * + */ + var $_method = array( 'encrypt' => 'encrypt', + 'decrypt' => 'decrypt' + ); + + /** + * class name of this class + * + */ + var $_name = __CLASS__; + + /** + * parent object from XFriendicaCiphers ($this) + * + */ + var $_parent = ''; + + /** + * chipher object from XFriendicaCiphers ($this) + * + */ + var $_cipher = ''; + + /** + * chipher_iv object from XFriendicaCiphers ($this) + * + */ + var $_cipher_iv = ''; + + /** + * Constructor + * + * @param string $data + * @param string $salt + * @param object $parent + */ + function __construct($data, $salt, $parent, $mode = 'inhertit') { + if (function_exists('mcrypt_module_open')) { + $this->_cipher = mcrypt_module_open($this->_func); + $this->_cipher_iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($this->_cipher), MCRYPT_RAND); + + switch ($mode) { + default: + $this->_parent = $parent; + if (empty($salt)&&is_object($this->_parent)) + $salt = $this->_parent->_options[$this->_func]; + if (!empty($data... [truncated message content] |