Created
September 22, 2013 03:27
-
-
Save fastcodecoq/6656414 to your computer and use it in GitHub Desktop.
function for hash messages (usage for chats)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <? | |
| function chunkMsg($content){ | |
| //coding message, this only will decode went the message is sended to recipient (execution time) | |
| $bytes = strlen($content); | |
| $chunks = $bytes/3; | |
| $part1 = str_replace("==", "", base64_encode(substr($content, 0, $chunks))); | |
| $part2 = str_replace("==", "", base64_encode(substr($content, $chunks, $chunks * 2))); | |
| $part3 = str_replace("==", "", base64_encode(substr($content, ($chunks*2) + 1, $chunks * 3))); | |
| $salt = hash("sha1", md5(time())); | |
| $map = array( | |
| "Q" => ":b:", | |
| "A" => ":c:", | |
| "D" => ":E:", | |
| "f" => ":H:" | |
| ); | |
| foreach ($map as $k => $char) { | |
| $part1 = str_replace($k, $char, $part1); | |
| $part1 = str_replace($k, $char, $part2); | |
| $part1 = str_replace($k, $char, $part3); | |
| } | |
| $content = base64_encode("{$part1}|{$salt}|{$part2}|{$salt}|{$part3}"); | |
| foreach ($map as $k => $char) | |
| $content = str_replace($k, $char, $content); | |
| $msg = array(); | |
| $offset = 8; | |
| $skip = 0; | |
| $bytes = strlen($content); | |
| for($i= 0; $i < $bytes; $i = $i+8){ | |
| $chunk = substr($content, $i, $offset); | |
| $msg[] = $chunk; | |
| } | |
| return $msg; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment