$width * $height * 3 * 0.9) { imagedestroy($image); throw new Exception("Message too long for image"); } $msgIndex = 0; for ($y = 0; $y < $height && $msgIndex < strlen($binaryMessage); $y++) { for ($x = 0; $x < $width && $msgIndex < strlen($binaryMessage); $x++) { $rgb = imagecolorat($image, $x, $y); $r = ($rgb >> 16) & 0xFF; $g = ($rgb >> 8) & 0xFF; $b = $rgb & 0xFF; if ($msgIndex < strlen($binaryMessage)) { $r = ($r & 0xFE) | intval($binaryMessage[$msgIndex]); $msgIndex++; } if ($msgIndex < strlen($binaryMessage)) { $g = ($g & 0xFE) | intval($binaryMessage[$msgIndex]); $msgIndex++; } if ($msgIndex < strlen($binaryMessage)) { $b = ($b & 0xFE) | intval($binaryMessage[$msgIndex]); $msgIndex++; } imagesetpixel($image, $x, $y, imagecolorallocate($image, $r, $g, $b)); } } $outputPath = 'Uploads/encoded_' . time() . '.png'; if (!file_exists('Uploads')) { mkdir('Uploads', 0777, true); } imagepng($image, $outputPath, 9); imagedestroy($image); return ['success' => true, 'path' => $outputPath]; } catch (Exception $e) { return ['success' => false, 'error' => $e->getMessage()]; } } function decodeMessage($imagePath) { try { if (!file_exists($imagePath) || filesize($imagePath) == 0) { throw new Exception("Invalid or empty image file"); } $image = imagecreatefromstring(file_get_contents($imagePath)); if ($image === false) { throw new Exception("Failed to load image"); } $width = imagesx($image); $height = imagesy($image); $binaryMessage = ''; $message = ''; $delimiter = "||END||"; $delimiterBinary = ''; foreach (str_split($delimiter) as $char) { $delimiterBinary .= str_pad(decbin(ord($char)), 8, '0', STR_PAD_LEFT); } for ($y = 0; $y < $height; $y++) { for ($x = 0; $x < $width; $x++) { $rgb = imagecolorat($image, $x, $y); $binaryMessage .= ($rgb >> 16) & 1; $binaryMessage .= ($rgb >> 8) & 1; $binaryMessage .= $rgb & 1; while (strlen($binaryMessage) >= 8) { $byte = substr($binaryMessage, 0, 8); $binaryMessage = substr($binaryMessage, 8); $char = chr(bindec($byte)); $message .= $char; if (strlen($message) >= strlen($delimiter) && substr($message, -strlen($delimiter)) === $delimiter) { imagedestroy($image); return ['success' => true, 'message' => substr($message, 0, -strlen($delimiter))]; } } } } imagedestroy($image); throw new Exception("No valid message found in image"); } catch (Exception $e) { return ['success' => false, 'error' => $e->getMessage()]; } } $result = ['success' => false, 'message' => '', 'path' => '']; if ($_SERVER['REQUEST_METHOD'] === 'POST') { if (isset($_POST['encode']) && isset($_FILES['image']) && isset($_POST['message'])) { $image = $_FILES['image']; $message = $_POST['message']; if ($image['error'] === UPLOAD_ERR_OK) { if ($image['size'] > 5 * 1024 * 1024) { $result = ['success' => false, 'error' => 'Image size exceeds 5MB limit']; } elseif (empty($message)) { $result = ['success' => false, 'error' => 'Message cannot be empty']; } else { $allowedTypes = ['image/jpeg', 'image/png']; if (in_array($image['type'], $allowedTypes)) { $tmpPath = $image['tmp_name']; if (!is_uploaded_file($tmpPath)) { $result = ['success' => false, 'error' => 'File upload failed or was modified']; } else { $result = encodeMessage($tmpPath, $message); } } else { $result = ['success' => false, 'error' => 'Invalid image format. Use JPG or PNG']; } } } else { $uploadErrors = [ UPLOAD_ERR_INI_SIZE => 'File too large for server configuration', UPLOAD_ERR_FORM_SIZE => 'File exceeds form size limit', UPLOAD_ERR_PARTIAL => 'File only partially uploaded', UPLOAD_ERR_NO_FILE => 'No file was uploaded', UPLOAD_ERR_NO_TMP_DIR => 'Missing temporary folder', UPLOAD_ERR_CANT_WRITE => 'Failed to write file to disk', UPLOAD_ERR_EXTENSION => 'A PHP extension stopped the file upload' ]; $errorMsg = isset($uploadErrors[$image['error']]) ? $uploadErrors[$image['error']] : 'Unknown upload error'; $result = ['success' => false, 'error' => $errorMsg]; } } elseif (isset($_POST['decode']) && isset($_FILES['decode_image'])) { $image = $_FILES['decode_image']; if ($image['error'] === UPLOAD_ERR_OK) { if ($image['size'] > 5 * 1024 * 1024) { $result = ['success' => false, 'error' => 'Image size exceeds 5MB limit']; } else { $allowedTypes = ['image/jpeg', 'image/png']; if (in_array($image['type'], $allowedTypes)) { $tmpPath = $image['tmp_name']; if (!is_uploaded_file($tmpPath)) { $result = ['success' => false, 'error' => 'File upload failed or was modified']; } else { $result = decodeMessage($tmpPath); } } else { $result = ['success' => false, 'error' => 'Invalid image format. Use JPG or PNG']; } } } else { $uploadErrors = [ UPLOAD_ERR_INI_SIZE => 'File too large for server configuration', UPLOAD_ERR_FORM_SIZE => 'File exceeds form size limit', UPLOAD_ERR_PARTIAL => 'File only partially uploaded', UPLOAD_ERR_NO_FILE => 'No file was uploaded', UPLOAD_ERR_NO_TMP_DIR => 'Missing temporary folder', UPLOAD_ERR_CANT_WRITE => 'Failed to write file to disk', UPLOAD_ERR_EXTENSION => 'A PHP extension stopped the file upload' ]; $errorMsg = isset($uploadErrors[$image['error']]) ? $uploadErrors[$image['error']] : 'Unknown upload error'; $result = ['success' => false, 'error' => $errorMsg]; } } } ?>
Hide secret messages in plain sight
Your messages are hidden using advanced steganography techniques that leave no visible traces.
Works seamlessly on both desktop and mobile devices with a responsive interface.
Encode and decode messages in seconds with our optimized processing algorithms.
Your secret message has been hidden in the image.