'."\n"); } else header("Content-type: text/html"); # ############################## ?> PNGCrypt <?php echo($version); ?>





PNGCrypt Source

© 2008 poebel
"); for($y = 0; $y < $x_max; $y++) { for($x = 0; $x < $y_max; $x++) { $chr = dechex(imagecolorat($img, $x, $y)); $chr = str_split($chr, 2); for($i = 0; $i <= 2; $i++) { if(hexdec($chr[$i]) != 0) { $chr[$i] = chr(hexdec($chr[$i])); $text .= $chr[$i]; } else { break 2; } } } } echo(vigenere_decrypt_ascii($text, $key, TRUE)); echo(""); imagedestroy($img); } # ################### ################### # text2picture function text2picture($text, $key = "default") { $text = vigenere_crypt_ascii(str_replace("\r", "", $_POST['text']), $key, TRUE).chr(0); $dimensions = ceil(sqrt((strlen($text) / 3))); $img = imagecreatetruecolor($dimensions, $dimensions); $random = FALSE; $pos = 0; for($y = 0; $y < $dimensions; $y++) { for($x = 0; $x < $dimensions; $x++) { for($i = 0; $i <= 2; $i++) { if(ord($text[($pos + $i)]) == 0) { if($random) { if(rand(0, 1)) $text[($pos + $i)] = chr(rand(97, 102)); else $text[($pos + $i)] = chr(rand(48, 57)); } else $random = TRUE; } } $color = imagecolorallocate($img, ord($text[$pos]), ord($text[($pos + 1)]), ord($text[($pos + 2)])); $pos += 3; imagesetpixel($img, $x, $y, $color); } } header("Content-type: image/png"); header('Content-Disposition: attachment; filename="encoded_image.png"'); #imagepng($img, "img.png"); imagepng($img); imagedestroy($img); } # ################### ################### # whole ascii chart vigenere encryption function vigenere_crypt_ascii($text, $key, $hex = FALSE) { $key = vigenere_expand_key(strlen($text), $key); for ($i = 0; $i < strlen($text); $i++) { $ascii_text[$i] = ord($text[$i]); $ascii_key[$i] = ord($key[$i]); $ascii_crypt[$i] = $ascii_text[$i] + $ascii_key[$i]; if ($ascii_crypt[$i] > 255) $ascii_crypt[$i] -= 256; if ($hex == TRUE AND strlen(dechex($ascii_crypt[$i])) == 1) $text_crypt .= "0".dechex($ascii_crypt[$i]); elseif ($hex == TRUE) $text_crypt .= dechex($ascii_crypt[$i]); else $text_crypt .= chr($ascii_crypt[$i]); } return $text_crypt; } # ################### ################### # whole ascii chart vigenere decryption function vigenere_decrypt_ascii($crypt, $key, $hex = FALSE) { if ($hex == TRUE) { $crypt = str_split($crypt, 2); $len = count($crypt); } else $len = strlen($crypt); $key = vigenere_expand_key($len, $key); for ($i = 0; $i < $len; $i++) { if ($hex == TRUE) $ascii_crypt[$i] = hexdec($crypt[$i]); else $ascii_crypt[$i] = ord($crypt[$i]); $ascii_key[$i] = ord($key[$i]); $ascii_text[$i] = $ascii_crypt[$i] - $ascii_key[$i]; if ($ascii_text[$i] < 0) $ascii_text[$i] += 256; $text_decrypt .= chr($ascii_text[$i]); } return $text_decrypt; } # ################### ################### # vigenere key adjustment function vigenere_expand_key($len, $key) { if (strlen($key) >= $len OR strlen($key) < 1) return $key; else return vigenere_expand_key($len, $key.$key); } # ################### ?>