Random Javascript and PHP generation
By Gareth Heyes (@hackvertor)
Published 18 years 5 months ago • Last updated March 22, 2025 • ⏱️ < 1 min read
This code was based on a CAPTCHA I wrote but it could be useful in other areas such as comment spam protection. The idea is that a few random code blocks are generated on the client and server side, so each language (PHP, Javascript) has the same code. For example:-
<pre lang="javascript"> num = 1330; for(i=0;i<2;i++) { num += 25; for(j=0;j<2;j++) { num += 25; } cfapqx = num </pre>The variables and the code are completely randomised so you should never get the same value, PHP will actually have the same code and therefore knows the result of the Javascript code block.
Here's the source, enjoy ;)
