note 81358 deleted from language.operators.bitwise by danielc

From: Date: Mon, 13 Apr 2009 16:15:23 +0000
Subject: note 81358 deleted from language.operators.bitwise by danielc
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-153177@lists.php.net to get a copy of this message
Note Submitter: nikodrumer at gmail dot com Reason: 2 ---- Sorry for my english, I'm French. We can create, a function to crypt/decrypt a string with a key : The function : <?php function _xor($message, $key) { $keylen = strlen($key); $messagelen = strlen($message); for($i=0; $i<$messagelen; $i++) $message[$i] = ~($message[$i]^$key[$i%$keylen]); return $message; } ?> To crypt : <?php echo _xor('My string', 'key'); ?> To decrypt : <?php echo _xor('…âíµ½¹¯£ý', 'key'); ?> For a better security, we can use sha1() and md5() : <?php echo _xor('My string', sha1(md5('key'))); ?>

« previous php.notes (#153177) next »