title: Found an HTMLScrambler in ASP/C#: Is there a way to do this with PHP?
body: <p>I'm in a project where I need a text scrambler that prevents people from accessing the text content of a site.</p>
  <p>I know that if the browser can render the site, there's always a way for the user to access the content. The user can take a picture of the screen with their phone as well. I already told them all that, but I still need to &quot;<em>make things more difficult to copy</em>&quot;.</p>
  <p>But browsing endless answers here in SO about how that is not possible, I've <a href="https://www.codeproject.com/Articles/22261/Simple-HTML-Scrambler" rel="nofollow noreferrer">found an HTMLScrambler</a>, that I think it works with ASP (I know nothing about it).</p>
  <p>Here's the screenshot, that look exactly what I need:</p>
  <p><a href="https://i.stack.imgur.com/1EqhW.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1EqhW.jpg" alt="enter image description here" /></a></p>
  <p>According to the script creator, you use it like this:</p>
  <h2>This is the text that goes into your HTML:</h2>
  <pre><code>&lt;%@ Register Assembly=&quot;Serverside.HTMLScrambler&quot; 
  
      Namespace=&quot;Serverside.HTMLScrambler&quot; TagPrefix=&quot;uc1&quot; %&gt;
  
  ......
  
  &lt;uc1:HTMLScrambler runat=&quot;server&quot; id=&quot;HTMLScrambler1&quot; Mode=&quot;HTML&quot;&gt;
    this text/html will be scrambled with HTML.
  &lt;/uc1:HTMLScrambler&gt;
  
  &lt;hr /&gt;
  
  &lt;uc1:HTMLScrambler runat=&quot;server&quot; id=&quot;HTMLScrambler2&quot; Mode=&quot;Javascript&quot;&gt;
    this text/html will be scrambled with Javascript.
  &lt;/uc1:HTMLScrambler&gt;
  </code></pre>
  <p>And it supports two ways to scramble: JavaScript or HTML. It's basically four small functions to get this working.</p>
  <h2>Here are the functions:</h2>
  <pre><code>// Used for javascript scramble
  private string GetHex(string character)
  {
      String[] hex = { &quot;00&quot;, &quot;01&quot;, &quot;02&quot;, &quot;03&quot;, &quot;04&quot;, &quot;05&quot;, &quot;06&quot;, &quot;07&quot;, &quot;08&quot;, &quot;09&quot;, 
           &quot;0A&quot;, &quot;0B&quot;, &quot;0C&quot;, &quot;0D&quot;, &quot;0E&quot;, &quot;0F&quot;, &quot;10&quot;, &quot;11&quot;, &quot;12&quot;, &quot;13&quot;, 
           &quot;14&quot;, &quot;15&quot;, &quot;16&quot;, &quot;17&quot;, &quot;18&quot;, &quot;19&quot;, &quot;1A&quot;, &quot;1B&quot;, &quot;1C&quot;, &quot;1D&quot;, 
           &quot;1E&quot;, &quot;1F&quot;, &quot;20&quot;, &quot;21&quot;, &quot;22&quot;, &quot;23&quot;, &quot;24&quot;, &quot;25&quot;, &quot;26&quot;, &quot;27&quot;, 
           &quot;28&quot;, &quot;29&quot;, &quot;2A&quot;, &quot;2B&quot;, &quot;2C&quot;, &quot;2D&quot;, &quot;2E&quot;, &quot;2F&quot;, &quot;30&quot;, &quot;31&quot;, 
           &quot;32&quot;, &quot;33&quot;, &quot;34&quot;, &quot;35&quot;, &quot;36&quot;, &quot;37&quot;, &quot;38&quot;, &quot;39&quot;, &quot;3A&quot;, &quot;3B&quot;, 
           &quot;3C&quot;, &quot;3D&quot;, &quot;3E&quot;, &quot;3F&quot;, &quot;40&quot;, &quot;41&quot;, &quot;42&quot;, &quot;43&quot;, &quot;44&quot;, &quot;45&quot;, 
           &quot;46&quot;, &quot;47&quot;, &quot;48&quot;, &quot;49&quot;, &quot;4A&quot;, &quot;4B&quot;, &quot;4C&quot;, &quot;4D&quot;, &quot;4E&quot;, &quot;4F&quot;, 
           &quot;50&quot;, &quot;51&quot;, &quot;52&quot;, &quot;53&quot;, &quot;54&quot;, &quot;55&quot;, &quot;56&quot;, &quot;57&quot;, &quot;58&quot;, &quot;59&quot;, 
           &quot;5A&quot;, &quot;5B&quot;, &quot;5C&quot;, &quot;5D&quot;, &quot;5E&quot;, &quot;5F&quot;, &quot;60&quot;, &quot;61&quot;, &quot;62&quot;, &quot;63&quot;, 
           &quot;64&quot;, &quot;65&quot;, &quot;66&quot;, &quot;67&quot;, &quot;68&quot;, &quot;69&quot;, &quot;6A&quot;, &quot;6B&quot;, &quot;6C&quot;, &quot;6D&quot;, 
           &quot;6E&quot;, &quot;6F&quot;, &quot;70&quot;, &quot;71&quot;, &quot;72&quot;, &quot;73&quot;, &quot;74&quot;, &quot;75&quot;, &quot;76&quot;, &quot;77&quot;, 
           &quot;78&quot;, &quot;79&quot;, &quot;7A&quot;, &quot;7B&quot;, &quot;7C&quot;, &quot;7D&quot;, &quot;7E&quot;, &quot;7F&quot;, &quot;80&quot;, &quot;81&quot;, 
           &quot;82&quot;, &quot;83&quot;, &quot;84&quot;, &quot;85&quot;, &quot;86&quot;, &quot;87&quot;, &quot;88&quot;, &quot;89&quot;, &quot;8A&quot;, &quot;8B&quot;, 
           &quot;8C&quot;, &quot;8D&quot;, &quot;8E&quot;, &quot;8F&quot;, &quot;90&quot;, &quot;91&quot;, &quot;92&quot;, &quot;93&quot;, &quot;94&quot;, &quot;95&quot;, 
           &quot;96&quot;, &quot;97&quot;, &quot;98&quot;, &quot;99&quot;, &quot;9A&quot;, &quot;9B&quot;, &quot;9C&quot;, &quot;9D&quot;, &quot;9E&quot;, &quot;9F&quot;, 
           &quot;A0&quot;, &quot;A1&quot;, &quot;A2&quot;, &quot;A3&quot;, &quot;A4&quot;, &quot;A5&quot;, &quot;A6&quot;, &quot;A7&quot;, &quot;A8&quot;, &quot;A9&quot;, 
           &quot;AA&quot;, &quot;AB&quot;, &quot;AC&quot;, &quot;AD&quot;, &quot;AE&quot;, &quot;AF&quot;, &quot;B0&quot;, &quot;B1&quot;, &quot;B2&quot;, &quot;B3&quot;, 
           &quot;B4&quot;, &quot;B5&quot;, &quot;B6&quot;, &quot;B7&quot;, &quot;B8&quot;, &quot;B9&quot;, &quot;BA&quot;, &quot;BB&quot;, &quot;BC&quot;, &quot;BD&quot;, 
           &quot;BE&quot;, &quot;BF&quot;, &quot;C0&quot;, &quot;C1&quot;, &quot;C2&quot;, &quot;C3&quot;, &quot;C4&quot;, &quot;C5&quot;, &quot;C6&quot;, &quot;C7&quot;, 
           &quot;C8&quot;, &quot;C9&quot;, &quot;CA&quot;, &quot;CB&quot;, &quot;CC&quot;, &quot;CD&quot;, &quot;CE&quot;, &quot;CF&quot;, &quot;D0&quot;, &quot;D1&quot;, 
           &quot;D2&quot;, &quot;D3&quot;, &quot;D4&quot;, &quot;D5&quot;, &quot;D6&quot;, &quot;D7&quot;, &quot;D8&quot;, &quot;D9&quot;, &quot;DA&quot;, &quot;DB&quot;, 
           &quot;DC&quot;, &quot;DD&quot;, &quot;DE&quot;, &quot;DF&quot;, &quot;E0&quot;, &quot;E1&quot;, &quot;E2&quot;, &quot;E3&quot;, &quot;E4&quot;, &quot;E5&quot;, 
           &quot;E6&quot;, &quot;E7&quot;, &quot;E8&quot;, &quot;E9&quot;, &quot;EA&quot;, &quot;EB&quot;, &quot;EC&quot;, &quot;ED&quot;, &quot;EE&quot;, &quot;EF&quot;, 
           &quot;F0&quot;, &quot;F1&quot;, &quot;F2&quot;, &quot;F3&quot;, &quot;F4&quot;, &quot;F5&quot;, &quot;F6&quot;, &quot;F7&quot;, &quot;F8&quot;, &quot;F9&quot;, 
           &quot;FA&quot;, &quot;FB&quot;, &quot;FC&quot;, &quot;FD&quot;, &quot;FE&quot;, &quot;FF&quot; };
      char[] chrBuffer = { Convert.ToChar(character) };
      byte[] bytBuffer = Encoding.Default.GetBytes(chrBuffer);
      int chrIndex = (int)bytBuffer[0];
      return hex[chrIndex];
  }
  
  // Used for html-scramble
  private string GetCharcode(string character)
  {
      char[] chrBuffer = { Convert.ToChar(character) };
      byte[] bytBuffer = Encoding.Default.GetBytes(chrBuffer);
      int chrIndex = (int)bytBuffer[0];
      return &quot;&amp;#&quot; + chrIndex + &quot;;&quot;;
  }
  </code></pre>
  <p>Is there any way to make this work or replicate this functionality in PHP?</p>