/** * encrypt * * encrypts the key * * @param array $srcArray The data array that contains the key data * @param string $keyType The type of the key to encrypt * * @return string Returns the encrypted string **/ public function encrypt($srcArray, $keyType = 'HOMEKEY') { $randAddOn = $this->generateRandomString(3); // get the key $key = $this->get_key($keyType); $key = $randAddOn . $key; if (!class_exists('PHPSecLib\\Crypt_Rijndael', false)) { import('phpseclib/Crypt/Rijndael', 'vendor'); } $rijndael = new \PHPSecLib\Crypt_Rijndael(); $rijndael->setKey($key); $out = $rijndael->encrypt(serialize($srcArray)); $hex = urlencode($randAddOn . base64_encode($out)); //wordwrap(urlencode($randAddOn.base64_encode($out)), 80,PHP_EOL , 1); return $hex; // return the key //return $hex; }
/** * Encrypt lic_key * @return type urlencode(base64(rijandel)) */ private function __get_decoded_key() { if (!class_exists('PHPSecLib\\Crypt_Rijndael', false)) { import('phpseclib/Crypt/Rijndael', 'vendor'); } $rijndael = new \PHPSecLib\Crypt_Rijndael(); $rijndael->setKey(self::NOCLAYER_PUBLIC_KEY); return urlencode(base64_encode($rijndael->encrypt($this->_lic->getKey()))); }