Sometimes you want to mention certain dangerous names in your HTML-page, but you don't want search-engines / web-crawlers / HTML-spiders to find them. Let's say you don't want to get shot by Russian agents after having told the truth about Ukraine war. What you could do easily is to obfuscate names using numeric HTML-entities. Here is Java source that does this for you:
public final class NameObfuscator { /** * @param name the name to obfuscate for HTML rendering. * @return the given name as hexadecimal HTML-entities. */ public static String toHtmlEntities(String name) { StringBuilder builder = new StringBuilder(); for (int i = 0; i < name.length(); i++) { char c = name.charAt(i); builder.append("&#x"+Integer.toHexString(c)+";"); } return builder.toString(); } private NameObfuscator() {} }
Mind that this does NOT protect against search-engines that
"expand" web-pages before they scan them, that means they render them
including execution of JavaScript
code and only then read their text.
Here is some test-source for the method above:
public static void main(String[] args) { final String[] names = new String[] { "Adolf Hitler", "Josef Stalin", "Wladimir Putin", "Donald Trump", }; for (String name : names) System.out.println(NameObfuscator.toHtmlEntities(name)); }
When you compile this with javac
and run it via java
, the output you will see is:
Adolf Hitler Josef Stalin Wladimir Putin Donald Trump
Copy these strings and replace the dangerous names in your HTML source-code by them.
Of course there are much better ways to obfuscate dangerous names,
but they are more complicated and may also not protect against sophisticated spiders.