Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Encrypt in Perl, De-encrypt in Javascript

Reply
Thread Tools

Encrypt in Perl, De-encrypt in Javascript

 
 
http://ejobseek.com
Guest
Posts: n/a
 
      09-01-2003
I got a javascript off the net which encrypt and de-encrypt HTML code so
that nobody can read the public html file.

here is the code of javascript and html. what i want to do is to encrypt in
perl then de-encrypt in javascript, because the original code is doing
encrypting and de-encrypting both in javascript.

the js file:
var
enkripsi="'1AQAPKRV'1G'2F'2C'02'02'02'02'02'02'02' 02dwlavkml'02glipkr'0:dmpo
l{c'0;'02'5@'2F'2C'2F'2C'02'02'02'02'02'02'02'02'0 2'02'02'02tcp'02imfg3'02'1
F'02gqacrg'0:dmpol{c,imfgcucn,tcnwg'0;'1@'2F'2C'02 '02'02'02'02'02'02'02'02'0
2'02'02tcp'02imfg0'1F'00'00'1@'2F'2C'02'02'02'02'0 2'02'02'02'02'02'02'02tcp'
02fmr'1F'00'00'1@'2F'2C'02'02'02'02'02'02'02'02'02 '02'02'02tcp'02ig{'02'1F'0
2dmpol{c,rcpcogvgp,tcnwg'1@'2F'2C'02'02'02'02'02'0 2'02'02'02'02'02'02tcp'02r
clhcle'02'1F'02imfg3,nglevj'1@'2F'2C'02'02'02'02'0 2'02'02'02'02'02'02'02dmp'
02'0:k'1F2'1@k'1Arclhcle'1@k))'0;'02'02'5@'2F'2C'0 2'02'02'02'02'02'02'02'02'
02'02'02'02'02'02'02kd'02'0:dmpol{c,ogvmfg,tcnwg'1 F'1F'00iwpcle'00'0;'02'5@'
2F'2C'02'02'02'02'02'02'02'02'02'02'02'02'02'02'02 '02'02'02'02'02imfg0)'1FQv
pkle,dpmoAjcpAmfg'0:imfg3,ajcpAmfgCv'0:k'0;/ig{'0;'1@'2F'2C'02'02'02'02'02'0
2'02'02'02'02'02'02'02'02'02'02'02'02'02'02fmr'1F' 00)'00'1@'2F'2C'02'02'02'0
2'02'02'02'02'02'02'02'02'02'02'02'02'5F'2F'2C'02' 02'02'02'02'02'02'02'02'02
'02'02'02'02'02'02gnqg'2F'2C'02'02'02'02'02'02'02' 02'02'02'02'02'02'02'02'02
'02'02'02'02kd'0:dmpol{c,ogvmfg,tcnwg'1F'1F'00vco` cj'00'0;'02'5@'2F'2C'02'02
'02'02'02'02'02'02'02'02'02'02'02'02'02'02'02'02'0 2'02'02'02'02'02imfg0)'1FQ
vpkle,dpmoAjcpAmfg'0:imfg3,ajcpAmfgCv'0:k'0ig{'0 ;'1@'2F'2C'02'02'02'02'02'
02'02'02'02'02'02'02'02'02'02'02'02'02'02'02'02'02 '02'02fmr'1F'00/'00'1@'2F'
2C'02'02'02'02'02'02'02'02'02'02'02'02'02'02'02'02 '02'02'02'02'5F'2F'2C'02'0
2'02'02'02'02'02'02'02'02'02'02'02'02'02'02'02'02' 02'02gnqg'2F'2C'02'02'02'0
2'02'02'02'02'02'02'02'02'02'02'02'02'02'02'02'02' 02'02'02'02kd'0:dmpol{c,og
vmfg,tcnwg'1F'1F'00zmp'00'0;'02'5@'2F'2C'02'02'02' 02'02'02'02'02'02'02'02'02
'02'02'02'02'02'02'02'02'02'02'02'02'02'02'02'02im fg0)'1FQvpkle,dpmoAjcpAmfg
'0:imfg3,ajcpAmfgCv'0:k'0;'7Gig{'0;'1@'2F'2C'02'02 '02'02'02'02'02'02'02'02'0
2'02'02'02'02'02'02'02'02'02'02'02'02'02'02'02'02' 02fmr'1F'00'7G'00'1@'2F'2C
'02'02'02'02'02'02'02'02'02'02'02'02'02'02'02'02'0 2'02'02'02'02'02'02'02'5F'
2F'2C'02'02'02'02'02'02'02'02'02'02'02'02'5F'2F'2C '2F'2C'02'02'02'02'02'02'0
2'02'02'02'02'02tcp'02fgipkrqkl{c'02'1F'02'2F'2C'0 2'02'02'02'02'02'02'02'02'
02'02'02'05tcp'02glipkrqk'1F'00'05)imfg0)'05'00'1@ '02vgiq'1F'00'00'1@'02vgiq
cqnk'1F'00'00'1@'05)'2F'2C'02'02'02'02'02'02'02'02 '02'02'02'02'05tcp'02rclhc
le'1@'05)'2F'2C'02'02'02'02'02'02'02'02'02'02'02'0 2'05rclhcle'1Fglipkrqk,ngl
evj'1@'05)'2F'2C'02'02'02'02'02'02'02'02'02'02'02' 02'05dmp'02'0:k'1F2'1@k'1A
rclhcle'1@k))'0;'05)'02'2F'2C'02'02'02'02'02'02'02 '02'02'02'02'02'05'5@'02vg
iq)'1FQvpkle,dpmoAjcpAmfg'0:glipkrqk,ajcpAmfgCv'0: k'0;'05)fmr)ig{)'05'0;'02'
5F'05)'2F'2C'02'02'02'02'02'02'02'02'02'02'02'02'0 5vgiqcqnk'1Fwlgqacrg'0:vgi
q'0;'1@'05)'2F'2C'02'02'02'02'02'02'02'02'02'02'02 '02'05fmawoglv,upkvg'0:vgi
qcqnk'0;'1@'05'1@'2F'2C'02'02'02'02'02'2F'2C'02'02 '02'02'02'02'02'02'02'02'0
2'02--'02dmpol{c,jcqkn,tcnwg'1F'05'7A'1AQAPKRV'7A'1G'05) fgipkrqkl{c)'05'7A'1
A-QAPKRV'7A'1G'05'1@'2F'2C'02'02'02'02'02'02'02'02'0 2'02'02'02dmpol{c,jcqkn,
tcnwg'1Ffgipkrqkl{c'1@'2F'2C'02'02'02'02'02'2F'2C' 02'02'02'02'02'02'02'02'02
'02'02'02kd'02'0:dmpol{c,rpgtkgu,tcnwg'1F'1F'00[c'00'0;'02'5@'2F'2C'02'02'02
'02'02'02'02'02'02'02'02'02'02'02'02'02jclfng'1Fuk lfmu,mrgl'0:'0;'1@'2F'2C'0
2'02'02'02'02'02'02'02'02'02'02'02'02'02'02'02jclf ng,fmawoglv,upkvgnl'0:'00'
1AJVON'1G'1AJGCF'1G'1AVKVNG'1GHcxcp'05q'02Dpgg'02V mmnq'02/'02HctcQapkrv'1A-V
KVNG'1G'1A-JGCF'1G'00'0;'1@'2F'2C'02'02'02'02'02'02'02'02'02' 02'02'02'02'02'
02'02jclfng,fmawoglv,upkvg'0:'05'1A@MF['1G'7A'1AQAPKRV'7A'1G'05'0;'1@'2F'2C'
02'02'02'02'02'02'02'02'02'02'02'02'02'02'02'02jcl fng,fmawoglv,upkvg'0:fgipk
rqkl{c'0;'1@'2F'2C'02'02'02'02'02'02'02'02'02'02'0 2'02'02'02'02'02jclfng,fma
woglv,upkvgnl'0:'05'7A'1A-QAPKRV'7A'1G'1A-@MF['1G'1A-JGCF'1G'1A-JVON'1G'05'0
;'1@'2F'2C'02'02'02'02'02'02'02'02'02'02'02'02'5F' 2F'2C'02'02'02'02'02'2F'2C
'02'02'02'02'02'02'02'02'02'02'02'02'1A'03//'02Jkvwle'02jcqknl{c'02//'1G'2F'
2C'02'02'02'02'02'02'02'02'02'02'02'02dmpol{c,rclh clecqnk,tcnwg'1Fdmpol{c,im
fgcucn,tcnwg,nglevj'1@'2F'2C'02'02'02'02'02'02'02' 02'02'02'02'02dmpol{c,rclh
cleglipkrqk,tcnwg'1Fdmpol{c,jcqkn,tcnwg,nglevj'1@' 2F'2C'02'02'02'02'02'02'02
'02'02'02'02'02dmpol{c,rgpvco`cjcl,tcnwg'1Fdmpol{c ,jcqkn,tcnwg,nglevj/dmpol{
c,imfgcucn,tcnwg,nglevj'1@'2F'2C'02'02'02'02'02'02 '02'02'5F'2F'2C'1A-QAPKRV'
1G"; teks=""; teksasli="";var panjang;panjang=enkripsi.length;for
(i=0;i<panjang;i++){
teks+=String.fromCharCode(enkripsi.charCodeAt(i)^2 ) }teksasli=unescape(teks)
;document.write(teksasli);


the html file:
<FORM action=index.html><B>Pase Javascript Code Here:</B><BR><I>Please
insert all code (including &lt;SCRIPT&gt;..&lt;/SCRIPT&gt;
tag)</I><BR><TEXTAREA class=input_1 name=kodeawal rows=8 wrap=virtual
cols=70></TEXTAREA>

<P><INPUT onclick="enkrip(this.form,this); return true" type=button
value=Encrypt name=B1>
<INPUT type=reset value=Reset name=B2> <INPUT type=hidden value=xor
name=metode> <INPUT type=hidden value=2 name=parameter> <INPUT
type=hidden
value=Tidak name=preview> </P><BR><BR><B>Encrypted JavaScript (Copy
from
here after encryption is complete)</B><BR><I>You should save this as a
file (like script.js) and include it into your<BR>HTML documents
using:</I> &lt;script src="script.js"&gt;<BR><TEXTAREA class=input_1
name=hasil rows=8 wrap=virtual cols=70>
</TEXTAREA><BR><BR><B>Stats:</B>

<BLOCKQUOTE><I>Original Length (Chars):</I> <INPUT class=input_stats
size=11 name=panjangasli><BR><I>Changes:</I> <INPUT
class=input_stats
size=11 name=pertambahan><BR><I>Encryption Length (Chars):</I>
<INPUT
class=input_stats size=11 name=panjangenkripsi>
</BLOCKQUOTE></FORM><BR><BR>

<SCRIPT language=javascript src="compiled.js"
type=text/javascript>
</SCRIPT>


 
Reply With Quote
 
 
 
 
Mina Naguib
Guest
Posts: n/a
 
      09-01-2003
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

http://ejobseek.com wrote:
> I got a javascript off the net which encrypt and de-encrypt HTML code so
> that nobody can read the public html file.
>
> here is the code of javascript and html. what i want to do is to encrypt in
> perl then de-encrypt in javascript, because the original code is doing
> encrypting and de-encrypting both in javascript.
>
> [snip encrypted junk]



It's not worth it. All such products are absolutely trivial to de-crypt.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQE/U5v8eS99pGMif6wRAlgpAJ4z972zOuWHYFwTT45fgw7xeLAsJQ CdGo0Z
65YxYlSehe1b14zMfMWlwkw=
=X01p
-----END PGP SIGNATURE-----

 
Reply With Quote
 
 
 
 
Jay Tilton
Guest
Posts: n/a
 
      09-01-2003
"http://ejobseek.com" <_@_._> wrote:

: I got a javascript off the net which encrypt and de-encrypt HTML code so
: that nobody can read the public html file.

How nicely pointless.

: what i want to do is to encrypt in
: perl then de-encrypt in javascript

Very good. What do you want from comp.lang.perl.misc readers?

: teks=""; teksasli="";var panjang;panjang=enkripsi.length;for
: (i=0;i<panjang;i++){
: teks+=String.fromCharCode(enkripsi.charCodeAt(i)^2 ) }teksasli=unescape(teks)
: ;document.write(teksasli);

All that does is XOR each character in the string with character
"\x02", then URI-unescape the result.

The encryption procedure would be to URI-escape a string, then perform
the XOR process on the result.

Useful tools for doing that in Perl would be the length() function,
the "^" operator, and the URI::Escape module.

 
Reply With Quote
 
James Willmore
Guest
Posts: n/a
 
      09-01-2003
On Mon, 1 Sep 2003 14:10:32 -0400
"http://ejobseek.com" <_@_._> wrote:
> I got a javascript off the net which encrypt and de-encrypt HTML
> code so that nobody can read the public html file.
>
> here is the code of javascript and html. what i want to do is to
> encrypt in perl then de-encrypt in javascript, because the original
> code is doing encrypting and de-encrypting both in javascript.


<perl>
Ugh. Well, if you want to do encryption in Perl, there are several
modules to aid you in this effort. Visit http://search.cpan.org/ to
get a listing of what's available. (use ppm if you're on a Windows
platform)
</perl>

<non-perl>
As far as trying to obuscate your HTML so no one gets it ... well ...
I don't know if that's a real possibility. Does this method work? If
it does, try it once with JavaScript turned off -or- use a text based
browser -or- LWP in Perl and see if it works. I'm going to see
myself, because javascript only works if it's on in the browser.
Plus, the browser needs to decode the HTML in order to render it. So,
the key to decode needs to be accessable in the browser. Which means,
someone can eventually find the key and then decode the HTML.

A strong copyright notice on your web page is just as effective, if
not more so, than trying to obuscate your code - because the law is on
your side when you copyright something. Obuscating or trying to
encode it without copyright notice is next to worthless, IMHO.
</non-perl>

HTH
--
Jim
---
Copyright notice: all code written by the author in this post is
considered GPL. http://gnu.org for more information.
---
a real quote ...
Linus Torvalids: "They are somking crack ...."
(http://www.eweek.com/article2/0,3959,1227150,00.asp)
---
a fortune quote ...
Man is the only animal that can remain on friendly terms with the
victims he intends to eat until he eats them. -- Samuel Butler
(1835-1902)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP encrypt of html text (password) and then Javascript decryption oldrich.svec@centrum.cz Javascript 1 12-18-2006 08:35 PM
PHP encrypt of html text (password) and then Javascript decryption oldrich.svec@centrum.cz Javascript 1 12-18-2006 06:50 PM
¿How to encrypt JavaScript Code? Eduardo F. Sandino Javascript 3 07-12-2006 12:21 AM
encrypt a letter in Javascript jayender.vs@gmail.com Javascript 8 05-27-2006 01:45 PM
Encrypt/Decrypt a structured file kevininstructor@state.or.us ASP .Net 1 09-25-2004 05:25 AM



Advertisments