Friday, 7 November 2025

ASCII to Text Converter

 

Read more 

We also Use

Command Prompt 

Use Bat  File .bat 

 notepad++

 excel convert code to text

https://youtu.be/98GqBJXT0nc?si=ibQR-GqCxk8WHiIG

____

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>Hex to Text Converter</title>

    <style>

        body {

            font-family: Arial, sans-serif;

            max-width: 800px;

            margin: 0 auto;

            padding: 20px;

            background-color: #f5f5f5;

        }

        .container {

            background-color: white;

            padding: 30px;

            border-radius: 10px;

            box-shadow: 0 2px 10px rgba(0,0,0,0.1);

        }

        h1 {

            color: #333;

            text-align: center;

        }

        .input-group {

            margin-bottom: 20px;

        }

        label {

            display: block;

            margin-bottom: 5px;

            font-weight: bold;

            color: #555;

        }

        textarea, input[type="text"] {

            width: 100%;

            padding: 10px;

            border: 2px solid #ddd;

            border-radius: 5px;

            font-size: 16px;

            box-sizing: border-box;

        }

        textarea {

            height: 100px;

            resize: vertical;

            font-family: monospace;

        }

        button {

            background-color: #007bff;

            color: white;

            padding: 12px 24px;

            border: none;

            border-radius: 5px;

            cursor: pointer;

            font-size: 16px;

            margin-right: 10px;

        }

        button:hover {

            background-color: #0056b3;

        }

        .result {

            margin-top: 20px;

            padding: 15px;

            background-color: #f8f9fa;

            border-radius: 5px;

            border-left: 4px solid #007bff;

        }

        .error {

            color: #dc3545;

            border-left-color: #dc3545;

        }

        .example {

            font-size: 14px;

            color: #666;

            margin-top: 5px;

        }

    </style>

</head>

<body>

    <div class="container">

        <h1>Hexadecimal to Text Converter</h1>

        

        <div class="input-group">

            <label for="hexInput">Hexadecimal Input:</label>

            <textarea id="hexInput" placeholder="Enter hexadecimal values (with or without spaces)"></textarea>

            <div class="example">Example: 48 65 6C 6C 6F 20 57 6F 72 6C 64 or 48656C6C6F20576F726C64</div>

        </div>


        <button onclick="convertHexToText()">Convert to Text</button>

        <button onclick="clearAll()">Clear</button>


        <div class="input-group">

            <label for="textOutput">Text Output:</label>

            <input type="text" id="textOutput" readonly placeholder="Converted text will appear here">

        </div>


        <div id="resultMessage"></div>

    </div>


    <script>

        function convertHexToText() {

            const hexInput = document.getElementById('hexInput').value;

            const textOutput = document.getElementById('textOutput');

            const resultMessage = document.getElementById('resultMessage');

            

            // Clear previous results

            resultMessage.innerHTML = '';

            resultMessage.className = '';

            

            if (!hexInput.trim()) {

                showResult('Please enter hexadecimal values', true);

                textOutput.value = '';

                return;

            }

            

            try {

                // Remove spaces and any non-hex characters

                const cleanHex = hexInput.replace(/[^0-9A-Fa-f]/g, '');

                

                // Check if the hex string has even length

                if (cleanHex.length % 2 !== 0) {

                    showResult('Error: Hexadecimal input must have even number of characters', true);

                    textOutput.value = '';

                    return;

                }

                

                let result = '';

                

                // Convert hex pairs to text

                for (let i = 0; i < cleanHex.length; i += 2) {

                    const hexPair = cleanHex.substr(i, 2);

                    const charCode = parseInt(hexPair, 16);

                    

                    // Check if it's a valid ASCII character

                    if (charCode >= 32 && charCode <= 126) {

                        result += String.fromCharCode(charCode);

                    } else {

                        result += `\\x${hexPair}`; // Show non-printable characters as escape sequences

                    }

                }

                

                textOutput.value = result;

                showResult(`Successfully converted ${cleanHex.length/2} bytes`, false);

                

            } catch (error) {

                showResult(`Error: ${error.message}`, true);

                textOutput.value = '';

            }

        }

        

        function showResult(message, isError) {

            const resultMessage = document.getElementById('resultMessage');

            resultMessage.textContent = message;

            resultMessage.className = isError ? 'result error' : 'result';

        }

        

        function clearAll() {

            document.getElementById('hexInput').value = '';

            document.getElementById('textOutput').value = '';

            document.getElementById('resultMessage').innerHTML = '';

            document.getElementById('resultMessage').className = '';

        }

        

        // Add some example data for quick testing

        document.getElementById('hexInput').value = '44 61 63 68 69 63 6B 79';

        

        // Allow pressing Enter in textarea to convert

        document.getElementById('hexInput').addEventListener('keypress', function(e) {

            if (e.key === 'Enter' && e.ctrlKey) {

                convertHexToText();

            }

        });

    </script>

</body>

</html>

0 comments:

Post a Comment

FB Gadgets | Template Designed by Fatakat PhotosCoolBThemes.com
Code by : paid web directory

https://www.google.co.uk/search?q=site%3Ablogspot.com+fbgadgets