/    Sign up×
Community /Pin to ProfileBookmark

URL encryption

I have found this code somewhere but I don’t know how to convert it into PHP. It will randomly encrypt given URL… Can someone do it?

[code=php]<SCRIPT language=JavaScript>
<!–
function encryptIt() {
// the following letters are going to be encrypted.
var letters = “abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ”;
var letterCode = new Array(
‘%61′,’%62′,’%63′,’%64′,’%65′,’%66′,’%67′,’%68′,’%69′,’%6a’,
‘%6b’,’%6c’,’%6d’,’%6e’,’%6f’,’%70′,’%71′,’%72′,’%73′,’%74′,
‘%75′,’%76′,’%77′,’%78′,’%79′,’%7a’,
‘%41′,’%42′,’%43′,’%44′,’%45′,’%46′,’%47′,’%48′,’%49′,’%4a’,
‘%4b’,’%4c’,’%4d’,’%4e’,’%4f’,’%50′,’%51′,’%52′,’%53′,’%54′,
‘%55′,’%56′,’%57′,’%58′,’%59′,’%5a’);

var _form = document.exf1;
var _formIn = _form.input.value.split(“.”);

var output = _formIn[0]+”.”;
for(var i = 0; i < _formIn[1].length; i++) {
if(letters.indexOf(_formIn[1].charAt(i))!=-1) {
if (letters.indexOf(_formIn[1].charAt(i))!=-1) {
// its a letter
var x = (Math.random()*1000)%10;
var j = letters.indexOf(_formIn[1].charAt(i));
if (x > 7) {
// j should be 0 through 25 for lowercase and 26 through 51 for uppercase
// switch them
if (j < 26) j += 26;
else j -= 26;
}
if (x < 3) { output += _formIn[1].charAt(i);
} else { output += letterCode[j]; }
} else { output += escape(_formIn[1].charAt(i)); }
} else { output += _formIn[1].charAt(i); }
}
for(var i=2;i<_formIn.length;i++)
output += “.”+_formIn[i];
_form.output.value = output;
}
function testIt() {
var _l = document.exf1.output.value;
if (_l.indexOf(“http://”)==-1) _l = “http://”+_l;
var myWin = window.open(_l,”TestWin”,”width=700,height=500,location=yes”);
}// End –>
</SCRIPT>[/code]

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@JonaJan 10.2004 — [font=arial]Since you can't open a new window in PHP, why not just simply send them as GET variables--I'm pretty sure they automatically change to their %-entities.[/font]

[b][J]ona[/b]
Copy linkTweet thisAlerts:
@ExtremeauthorJan 10.2004 — Oh, but in fact, I ment to eject this part with opening window.. I was just interested how to return encrpyted URL if URL is in some variable..

ex. $url = "http://host.com"

....

return "$encrypted_url"

I thought I would understand how it was done if I could just change this script into PHP since I haven't found any example on net that uses PHP to encrypte URL...

Here is the presentation of script:

http://www.haiyang.com/services/info_security/haiyang_url_encrypt/
Copy linkTweet thisAlerts:
@Jeff_MottJan 10.2004 — Just an FYI: this encryption scheme you speak of is so uncomplicated that it does not even fit the definition of encryption. It is, in practical application, quite useless.
Copy linkTweet thisAlerts:
@ExtremeauthorJan 10.2004 — Yes, that is true. But there are some practical uses.. FOr me at least..
Copy linkTweet thisAlerts:
@JonaJan 10.2004 — [i]Originally posted by Extreme [/i]

[B]Yes, that is true. But there are some practical uses.. For me at least.. [/B][/QUOTE]


[font=arial]Mind enlightening us as to what those uses could be?[/font]

[b][J]ona[/b]
×

Success!

Help @Extreme spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.27,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...