You can use direct access to this page from your browser address bar.
Type string that you need to encode/decode with algorithm according to next schema:
https://md5calc.com/html/<TYPE:enc|dec>/<PHRASE>
For example to visit page that contains encoded "<strong>" you can just visit url:
https://md5calc.com/html/enc/<strong>
The another cool thing is that you can specify "json" or "plain" mode into URL and you
will get only encoded/decoded in response.
Schema of this future:
https://md5calc.com/html/<TYPE:enc|dec>.<OUTPUT:plain|json>/<PHRASE>
Example:
https://md5calc.com/html/enc.plain/<strong>
Will output:
<strong>
We have removed CORS restriction so you can use direct access to htmlspecialchars encode/decode in your javascript applications via AJAX.
Example:
var toEncode = '<strong>';
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function () {
if (xhr.readyState == 4 && xhr.status == 200) {
console.log('String "'+toEncode+'"'
+' encoded with htmlspecialchars is'
+' "'+JSON.parse(xhr.response)+'"'
);
};
};
xhr.open('GET', 'https://md5calc.com/html/enc.json/'+encodeURIComponent(toEncode), true);
xhr.send();
Will output:
String "<strong>" encoded with htmlspecialchars is "<strong>"
You can use direct access to this function in your applications.
PHP Example:
<?php
$str = '<strong>';
$url ='http://md5calc.sv/html/enc.plain/'.urlencode($str);
$htmlencoded = file_get_contents($url);
echo 'String "'.htmlspecialchars($str, ENT_QUOTES|ENT_IGNORE)
.'" encoded with htmlspecialchars is "'
.htmlspecialchars($htmlencoded, ENT_QUOTES|ENT_IGNORE).'"'
;
Will output:
String "<strong>" encoded with htmlspecialchars is "<strong>"
Keep in mind that this example no make sense because PHP has builtin functions htmlspecialchars() and htmlspecialchars_decode() which do the same.
<?php
$str = '<script>';
$htmlSpecialCharsEncodedStr = htmlspecialchars($str, ENT_QUOTES | ENT_IGNORE);
$htmlSpecialCharsDecodedStr = htmlspecialchars_decode($htmlSpecialCharsEncodedStr, ENT_QUOTES);
echo '<pre>';
echo htmlspecialchars($str, ENT_QUOTES|ENT_IGNORE).PHP_EOL
.' → '.htmlspecialchars($htmlSpecialCharsEncodedStr, ENT_QUOTES|ENT_IGNORE).PHP_EOL
.' → '.htmlspecialchars($htmlSpecialCharsDecodedStr, ENT_QUOTES|ENT_IGNORE).PHP_EOL
;
echo '</pre>';