Encrypt in Perl, De-encrypt in Javascript

Discussion in 'Perl Misc' started by http://ejobseek.com, Sep 1, 2003.

  1. 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'02'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'02'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'02'02'02'02'02'02'02tcp'02r
    clhcle'02'1F'02imfg3,nglevj'1@'2F'2C'02'02'02'02'02'02'02'02'02'02'02'02dmp'
    02'0:k'1F2'1@k'1Arclhcle'1@k))'0;'02'02'5@'2F'2C'02'02'02'02'02'02'02'02'02'
    02'02'02'02'02'02'02kd'02'0:dmpol{c,ogvmfg,tcnwg'1F'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'02'02'02'02'02'02imfg0)'1FQ
    vpkle,dpmoAjcpAmfg'0:imfg3,ajcpAmfgCv'0:k'0;)ig{'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'02imfg0)'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'02'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'02'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'02'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'05vgiqcqnk'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'02'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'1Fuklfmu,mrgl'0:'0;'1@'2F'2C'0
    2'02'02'02'02'02'02'02'02'02'02'02'02'02'02'02jclfng,fmawoglv,upkvgnl'0:'00'
    1AJVON'1G'1AJGCF'1G'1AVKVNG'1GHcxcp'05q'02Dpgg'02Vmmnq'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'02jclfng,fmawoglv,upkvg'0:fgipk
    rqkl{c'0;'1@'2F'2C'02'02'02'02'02'02'02'02'02'02'02'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,rclhclecqnk,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>
     
    http://ejobseek.com, Sep 1, 2003
    #1
    1. Advertising

  2. http://ejobseek.com

    Mina Naguib Guest

    -----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/U5v8eS99pGMif6wRAlgpAJ4z972zOuWHYFwTT45fgw7xeLAsJQCdGo0Z
    65YxYlSehe1b14zMfMWlwkw=
    =X01p
    -----END PGP SIGNATURE-----
     
    Mina Naguib, Sep 1, 2003
    #2
    1. Advertising

  3. http://ejobseek.com

    Jay Tilton Guest

    "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.
     
    Jay Tilton, Sep 1, 2003
    #3
  4. 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)
     
    James Willmore, Sep 1, 2003
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    1
    Views:
    434
    Daniel Martin
    Jun 16, 2007
  2. Maran Chandrasekar

    Perl Encrypt / Ruby Decrypt

    Maran Chandrasekar, Feb 16, 2009, in forum: Ruby
    Replies:
    1
    Views:
    266
    Brian Candler
    Feb 16, 2009
  3. uncle
    Replies:
    2
    Views:
    143
    Michele Dondi
    Jun 16, 2007
  4. Replies:
    8
    Views:
    143
    Thomas 'PointedEars' Lahn
    May 27, 2006
  5. Eduardo F. Sandino

    ┬┐How to encrypt JavaScript Code?

    Eduardo F. Sandino, Jul 11, 2006, in forum: Javascript
    Replies:
    3
    Views:
    268
    cwdjrxyz
    Jul 12, 2006
Loading...

Share This Page