home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / srev13g.zip / enc_form.rsp < prev    next >
Text File  |  1999-04-23  |  20KB  |  531 lines

  1. <!-- This is an includable file that contains several javascript procedures that
  2.      can be used to encrypt  selected fields in an HTML form, for transmittal
  3.      to an SRE-http web server.
  4.  
  5.      You should include this file in the <HEAD> section of the html
  6.      document (that contains the FORM you wish to encrypt) 
  7.  
  8.  
  9. The main procedures are:
  10.  
  11.  comp_md5(astring)
  12.  clear_fields(element1,[element])
  13.  do_encrypt(avalue,element)
  14.  
  15. Usage:
  16.   To encrypt form elements, the following steps are needed:
  17.      i) include this file in the document containing the FORM to be encrytped
  18.     ii) specify in the <FORM>: <input type="hidden" name="NONCE" value=0>
  19.                and <input type="hidden" name="verify" value=0>
  20.    iii) aks for a shared-secret password, and generate the client's
  21.         encryption-key using the comp_md5 procedure
  22.     iv) specify hidden elements to store encrypted values of variables, and
  23.         use the do_encrypt procedure to encrypt values
  24.      v) clear unencrypted values by calling clear_elements prior to SUBMIT.
  25.     vi) after submission, the server uses sref_form_decrypt to decrypt
  26.  
  27. The following describes these steps in greater detail:           
  28.  
  29.   i) Include this script in the html document that contains the
  30.      FORM you wish to encrypt.
  31.      The easiest way to do this is to include the following "ssi" statement
  32.          < !-- include enc_Form.rsp -- >
  33.      in the <HEAD> of the HTML document that contains the form you want
  34.      encrypted (more precisely, of the form containing elements you want
  35.      to encrypt).  
  36.      This assume that ENC_FORM.RSP is in the (possibly host-specific) data
  37.      directory, and that the HTML document is ssi-enabled (for example, it has 
  38.      a .SHT extension).
  39.  
  40.   ii) Include the following elements in your FORM
  41.          <input type="hidden" name="NONCE" value=0>
  42.          <input type="hidden" name="VERIFY" value=0>
  43.  
  44.       To be safe, this should appear immediately after the <FORM> element.
  45.   
  46.  iii) You must ask the client to enter her "shared-secret" password
  47.       for this site, and then compute an MD5 hash from this.
  48.       The easiest way to do this is by using the comp_md5
  49.       javascript procedure (that is included in this file).  
  50.  
  51.       For example, include the following in the body of the HTML document:
  52.  
  53.           Please enter your <b>shared-secret</b> password:  
  54.              <INPUT type="text" name="your_pwd" value=""
  55.               size=20 onChange="comp_md5(this.form.your_pwd) ; return true" > 
  56.  
  57.       Notes:
  58.         a) the shared-secret is case insensitive (it will be capitalized)
  59.         a) comp_md5 will also set the value of the "nonce" and "verify" variables.
  60.         b) SRE-http will store the client's "shared secret" as one of her 
  61.            "secret privileges". For example, if her shared-secret is foobar,
  62.            the client's USERS.IN entry might ?ENCRYPT:FOOBAR as a secret
  63.            privilege. 
  64.  
  65.   iv) For each element in the FORM that you want to encrypt, you should:
  66.         a) specify a hidden element which will contain it's encrypted value.
  67.         b) set this hidden element's value using the do_encrypt procedure
  68.            Do_encrypt expects two values:
  69.                the string to be encrypted
  70.                the form element (as initialized in setp a) used to store this 
  71.                encrypted value it (the element name, NOT it's value attribute).
  72.  
  73.       For example:
  74.  
  75.          <input type="hidden" name="secretname_enc" value=0>
  76.          Enter your  secret name:
  77.            <input type="text" name="secretname" size=20
  78.             onChange="do_encrypt(this.form.secretname.value,this.form.secretname_enc) ; 
  79.                             return true ">
  80.  
  81.    v) Before submitting the FORM, you MUST clear the to-be-encrypted values. 
  82.       This can be done by including a call to the clear_fields procedure 
  83.       as an attribute of the SUBMIT element.
  84.  
  85.       For example:
  86.  
  87.          <input type="submit" value="submit now!" 
  88.           onClick="clear_fields(this.secretname,this.secretaction,this.myvalue);
  89.                   return true ">
  90.         
  91.       Note that you can specify an unlimited number of fields to clear; using
  92.       either the this.field_name, or the formname.field_name specficiation. 
  93.       You should specify the element name, and NOT it's value field. 
  94.   
  95.              THIS STEP IS CRUCIAL -- if you neglect to do this, the
  96.              unencrypted input will be sent!
  97.  
  98.    vi) The addon that processes the request generated when this form is 
  99.        submitted should be aware of which elements are encrypted.  The values 
  100.        for these parameters can then be decrypted with call to the 
  101.        SREF_FORM_DECRYPT procedure (that's part of the SRE-http macrospace
  102.        library).
  103.  
  104.        For example, extending the preceding example, to decrypt "secretname_enc", 
  105.        the addon should:
  106.          a) get the "nonce" parameters (which was set in step iii)
  107.          b) get the appropriate "secret privilege" -- this may (or may not)
  108.              be the ?ENCRYPT:pwd  "secret privilege".
  109.              Note that secret privileges are found in the "PRIVSET" argument 
  110.              sent to addons -- see MK_ADDON.HTM or SREHTTP.HTM for more 
  111.              details.
  112.          c) Compute the encryption key (the same encryption key is used for
  113.             all encrypted elements), and compare it against the "verify"
  114.             element. If there is a mismatch, ask the client to resubmit.
  115.          c) decrypt this value using:
  116.                 newvalue=sref_decrypt(encvalue,nonce,apwd)
  117.              where:
  118.                  encvalue is the encrypted response
  119.                  nonce is from step a
  120.                  apwd is from step b.
  121.      
  122.   -->
  123.  
  124. <SCRIPT>
  125. <!--
  126.  
  127. // some variables
  128.   var themd5=0
  129.   var ix=0 ; var iy=0 ; var iz=0
  130.  
  131.  var ascii="01234567890123456789012345678901" +
  132.            " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ"+
  133.            "[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~";
  134.  
  135. /*   md5.jvs 1.0b 27/06/96
  136.   *
  137.   * Javascript implementation of the RSA Data Security, Inc. MD5
  138.   * Message-Digest Algorithm.
  139.   *
  140.   * Copyright (c) 1996 Henri Torgemane. All Rights Reserved.
  141.   *
  142.   * Permission to use, copy, modify, and distribute this software
  143.   * and its documentation for any purposes and without
  144.   * fee is hereby granted provided that this copyright notice
  145.   * appears in all copies. 
  146.   *
  147.   * Of course, this soft is provided "as is" without express or implied
  148.   * warranty of any kind.
  149.   */
  150.  function array(n) {
  151.    for(i=0;i<n;i++) this[i]=0;
  152.    this.length=n; }
  153.  /* Some basic logical functions had to be rewritten because of a bug in
  154.   * Javascript.. Just try to compute 0xffffffff >> 4 with it..
  155.   * Of course, these functions are slower than the original would be, but
  156.   * at least, they work!
  157.   */
  158.  function integer(n) { return n%(0xffffffff+1); }
  159.  function shr(a,b) {
  160.    a=integer(a);
  161.    b=integer(b);
  162.    if (a-0x80000000>=0) {
  163.      a=a%0x80000000;
  164.      a>>=b;
  165.      a+=0x40000000>>(b-1);   } 
  166.    else
  167.      a>>=b;
  168.    return a; }
  169.  function shl1(a) {
  170.    a=a%0x80000000;
  171.    if (a&0x40000000==0x40000000)
  172.    {     a-=0x40000000;  
  173.      a*=2;
  174.      a+=0x80000000;  }
  175.    else
  176.      a*=2;
  177.    return a; }
  178.  function shl(a,b) {
  179.    a=integer(a);
  180.    b=integer(b);
  181.    for (var i=0;i<b;i++) a=shl1(a);
  182.    return a; }
  183.  function and(a,b) {
  184.    a=integer(a);
  185.    b=integer(b);
  186.    var t1=(a-0x80000000);
  187.    var t2=(b-0x80000000);
  188.    if (t1>=0) 
  189.      if (t2>=0) 
  190.        return ((t1&t2)+0x80000000);
  191.      else
  192.        return (t1&b);
  193.    else
  194.      if (t2>=0)
  195.        return (a&t2);
  196.      else
  197.        return (a&b);   }
  198.  function or(a,b) {
  199.    a=integer(a);
  200.    b=integer(b);
  201.    var t1=(a-0x80000000);
  202.    var t2=(b-0x80000000);
  203.    if (t1>=0) 
  204.      if (t2>=0) 
  205.        return ((t1|t2)+0x80000000);
  206.      else
  207.        return ((t1|b)+0x80000000);
  208.    else
  209.      if (t2>=0)
  210.        return ((a|t2)+0x80000000);
  211.      else
  212.        return (a|b);   }
  213.  function xor(a,b) {
  214.    a=integer(a);
  215.    b=integer(b);
  216.    var t1=(a-0x80000000);
  217.    var t2=(b-0x80000000);
  218.    if (t1>=0) 
  219.      if (t2>=0) 
  220.        return (t1^t2);
  221.      else
  222.        return ((t1^b)+0x80000000);
  223.    else
  224.      if (t2>=0)
  225.        return ((a^t2)+0x80000000);
  226.      else
  227.        return (a^b);   }
  228.  function not(a) {
  229.    a=integer(a);
  230.    return (0xffffffff-a); }
  231.  /* Here begin the real algorithm */
  232.      var state = new array(4); 
  233.      var count = new array(2);
  234.          count[0] = 0;
  235.          count[1] = 0;                     
  236.      var buffer = new array(64); 
  237.      var transformBuffer = new array(16); 
  238.      var digestBits = new array(16);
  239.      var S11 = 7;     var S12 = 12;     var S13 = 17;
  240.      var S14 = 22;     var S21 = 5;     var S22 = 9;
  241.      var S23 = 14;     var S24 = 20;     var S31 = 4;
  242.      var S32 = 11;     var S33 = 16;     var S34 = 23;
  243.      var S41 = 6;     var S42 = 10;     var S43 = 15;
  244.      var S44 = 21;
  245.      function F(x,y,z) {return or(and(x,y),and(not(x),z));     }
  246.      function G(x,y,z) {return or(and(x,z),and(y,not(z)));     }
  247.      function H(x,y,z) {return xor(xor(x,y),z);     }
  248.      function I(x,y,z) {return xor(y ,or(x , not(z)));     }
  249.      function rotateLeft(a,n) {return or(shl(a, n),(shr(a,(32 - n))));     }
  250.      function FF(a,b,c,d,x,s,ac) {
  251.          a = a+F(b, c, d) + x + ac;
  252.          a = rotateLeft(a, s);
  253.          a = a+b;
  254.          return a;     }
  255.      function GG(a,b,c,d,x,s,ac) {
  256.          a = a+G(b, c, d) +x + ac;
  257.          a = rotateLeft(a, s);
  258.          a = a+b;
  259.          return a;     }
  260.      function HH(a,b,c,d,x,s,ac) {
  261.          a = a+H(b, c, d) + x + ac;
  262.          a = rotateLeft(a, s);
  263.          a = a+b;
  264.          return a;     }
  265.      function II(a,b,c,d,x,s,ac) {
  266.          a = a+I(b, c, d) + x + ac;
  267.          a = rotateLeft(a, s);
  268.          a = a+b;
  269.          return a;     }
  270.      function transform(buf,offset) { 
  271.          var a=0, b=0, c=0, d=0; 
  272.          var x = transformBuffer;
  273.          a = state[0];
  274.          b = state[1];
  275.          c = state[2];
  276.          d = state[3];
  277.          for (i = 0; i < 16; i++) {
  278.              x[i] = and(buf[i*4+offset],0xff);
  279.              for (j = 1; j < 4; j++) {
  280.                  x[i]+=shl(and(buf[i*4+j+offset] ,0xff), j * 8);      }         }
  281.          /* Round 1 */
  282.          a = FF ( a, b, c, d, x[ 0], S11, 0xd76aa478); /* 1 */
  283.          d = FF ( d, a, b, c, x[ 1], S12, 0xe8c7b756); /* 2 */
  284.          c = FF ( c, d, a, b, x[ 2], S13, 0x242070db); /* 3 */
  285.          b = FF ( b, c, d, a, x[ 3], S14, 0xc1bdceee); /* 4 */
  286.          a = FF ( a, b, c, d, x[ 4], S11, 0xf57c0faf); /* 5 */
  287.          d = FF ( d, a, b, c, x[ 5], S12, 0x4787c62a); /* 6 */
  288.          c = FF ( c, d, a, b, x[ 6], S13, 0xa8304613); /* 7 */
  289.          b = FF ( b, c, d, a, x[ 7], S14, 0xfd469501); /* 8 */
  290.          a = FF ( a, b, c, d, x[ 8], S11, 0x698098d8); /* 9 */
  291.          d = FF ( d, a, b, c, x[ 9], S12, 0x8b44f7af); /* 10 */
  292.          c = FF ( c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */
  293.          b = FF ( b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */
  294.          a = FF ( a, b, c, d, x[12], S11, 0x6b901122); /* 13 */
  295.          d = FF ( d, a, b, c, x[13], S12, 0xfd987193); /* 14 */
  296.          c = FF ( c, d, a, b, x[14], S13, 0xa679438e); /* 15 */
  297.          b = FF ( b, c, d, a, x[15], S14, 0x49b40821); /* 16 */
  298.          /* Round 2 */
  299.          a = GG ( a, b, c, d, x[ 1], S21, 0xf61e2562); /* 17 */
  300.          d = GG ( d, a, b, c, x[ 6], S22, 0xc040b340); /* 18 */
  301.          c = GG ( c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */
  302.          b = GG ( b, c, d, a, x[ 0], S24, 0xe9b6c7aa); /* 20 */
  303.          a = GG ( a, b, c, d, x[ 5], S21, 0xd62f105d); /* 21 */
  304.          d = GG ( d, a, b, c, x[10], S22,  0x2441453); /* 22 */
  305.          c = GG ( c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */
  306.          b = GG ( b, c, d, a, x[ 4], S24, 0xe7d3fbc8); /* 24 */
  307.          a = GG ( a, b, c, d, x[ 9], S21, 0x21e1cde6); /* 25 */
  308.          d = GG ( d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */
  309.          c = GG ( c, d, a, b, x[ 3], S23, 0xf4d50d87); /* 27 */
  310.          b = GG ( b, c, d, a, x[ 8], S24, 0x455a14ed); /* 28 */
  311.          a = GG ( a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */
  312.          d = GG ( d, a, b, c, x[ 2], S22, 0xfcefa3f8); /* 30 */
  313.          c = GG ( c, d, a, b, x[ 7], S23, 0x676f02d9); /* 31 */
  314.          b = GG ( b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */
  315.          /* Round 3 */
  316.          a = HH ( a, b, c, d, x[ 5], S31, 0xfffa3942); /* 33 */
  317.          d = HH ( d, a, b, c, x[ 8], S32, 0x8771f681); /* 34 */
  318.          c = HH ( c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */
  319.          b = HH ( b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */
  320.          a = HH ( a, b, c, d, x[ 1], S31, 0xa4beea44); /* 37 */
  321.          d = HH ( d, a, b, c, x[ 4], S32, 0x4bdecfa9); /* 38 */
  322.          c = HH ( c, d, a, b, x[ 7], S33, 0xf6bb4b60); /* 39 */
  323.          b = HH ( b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */
  324.          a = HH ( a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */
  325.          d = HH ( d, a, b, c, x[ 0], S32, 0xeaa127fa); /* 42 */
  326.          c = HH ( c, d, a, b, x[ 3], S33, 0xd4ef3085); /* 43 */
  327.          b = HH ( b, c, d, a, x[ 6], S34,  0x4881d05); /* 44 */
  328.          a = HH ( a, b, c, d, x[ 9], S31, 0xd9d4d039); /* 45 */
  329.          d = HH ( d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */
  330.          c = HH ( c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */
  331.          b = HH ( b, c, d, a, x[ 2], S34, 0xc4ac5665); /* 48 */
  332.          /* Round 4 */
  333.          a = II ( a, b, c, d, x[ 0], S41, 0xf4292244); /* 49 */
  334.          d = II ( d, a, b, c, x[ 7], S42, 0x432aff97); /* 50 */
  335.          c = II ( c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */
  336.          b = II ( b, c, d, a, x[ 5], S44, 0xfc93a039); /* 52 */
  337.          a = II ( a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */
  338.          d = II ( d, a, b, c, x[ 3], S42, 0x8f0ccc92); /* 54 */
  339.          c = II ( c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */
  340.          b = II ( b, c, d, a, x[ 1], S44, 0x85845dd1); /* 56 */
  341.          a = II ( a, b, c, d, x[ 8], S41, 0x6fa87e4f); /* 57 */
  342.          d = II ( d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */
  343.          c = II ( c, d, a, b, x[ 6], S43, 0xa3014314); /* 59 */
  344.          b = II ( b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */
  345.          a = II ( a, b, c, d, x[ 4], S41, 0xf7537e82); /* 61 */
  346.          d = II ( d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */
  347.          c = II ( c, d, a, b, x[ 2], S43, 0x2ad7d2bb); /* 63 */
  348.          b = II ( b, c, d, a, x[ 9], S44, 0xeb86d391); /* 64 */
  349.          state[0] +=a;
  350.          state[1] +=b;
  351.          state[2] +=c;
  352.          state[3] +=d;     }
  353.      function init() {
  354.          count[0]=count[1] = 0;
  355.          state[0] = 0x67452301;
  356.          state[1] = 0xefcdab89;
  357.          state[2] = 0x98badcfe;
  358.          state[3] = 0x10325476;
  359.          for (i = 0; i < digestBits.length; i++)
  360.              digestBits[i] = 0;     }
  361.      function update(b) { 
  362.          var index,i;
  363.          index = and(shr(count[0],3) , 0x3f);
  364.          if (count[0]<0xffffffff-7) 
  365.            count[0] += 8;
  366.          else {
  367.            count[1]++;
  368.            count[0]-=0xffffffff+1;
  369.            count[0]+=8;         }
  370.          buffer[index] = and(b,0xff);
  371.          if (index  >= 63) {
  372.              transform(buffer, 0);
  373.          }     }
  374.      function finish() {
  375.          var bits = new array(8);
  376.          var     padding; 
  377.          var     i=0, index=0, padLen=0;
  378.          for (i = 0; i < 4; i++) {
  379.              bits[i] = and(shr(count[0],(i * 8)), 0xff);         }
  380.          for (i = 0; i < 4; i++) {
  381.              bits[i+4]=and(shr(count[1],(i * 8)), 0xff);         }
  382.          index = and(shr(count[0], 3) ,0x3f);
  383.          padLen = (index < 56) ? (56 - index) : (120 - index);
  384.          padding = new array(64); 
  385.          padding[0] = 0x80;
  386.          for (i=0;i<padLen;i++)
  387.            update(padding[i]);
  388.          for (i=0;i<8;i++) 
  389.            update(bits[i]);
  390.          for (i = 0; i < 4; i++) {
  391.              for (j = 0; j < 4; j++) {
  392.                  digestBits[i*4+j] = and(shr(state[i], (j * 8)) , 0xff);             }
  393.          }      }
  394.  /* End of the MD5 algorithm */
  395.  function hexa(n) {
  396.   var hexa_h = "0123456789abcdef";  var hexa_c="";   var hexa_m=n;
  397.   for (hexa_i=0;hexa_i<8;hexa_i++) {
  398.     hexa_c=hexa_h.charAt(Math.abs(hexa_m)%16)+hexa_c;
  399.     hexa_m=Math.floor(hexa_m/16);  }
  400.   return hexa_c; }
  401.  
  402. function hextodec(ahex,llen) {
  403.   var smm=0
  404.   var xlist='0123456789ABCDEF'
  405.    var afact=1
  406.    for (ir=llen-1; ir>=0;ir--) {
  407.        var acc=ahex.charAt(ir)
  408.        iind=xlist.indexOf(acc)   
  409.        smm=smm+(iind*afact)
  410.        afact=afact*16
  411.    }
  412.    return  smm
  413.  }
  414.  
  415.  
  416.  
  417.  function MD5(your_pwd)  {
  418.   var l,s,k,ka,kb,kc,kd;
  419.   init();
  420.   for (k=0;k<your_pwd.length;k++) {
  421.     l=your_pwd.charAt(k);
  422.     update(ascii.lastIndexOf(l));  }
  423.   finish();
  424.   ka=kb=kc=kd=0;
  425.   for (i=0;i<4;i++) ka+=shl(digestBits[15-i], (i*8));
  426.   for (i=4;i<8;i++) kb+=shl(digestBits[15-i], ((i-4)*8));
  427.   for (i=8;i<12;i++) kc+=shl(digestBits[15-i], ((i-8)*8));
  428.   for (i=12;i<16;i++) kd+=shl(digestBits[15-i], ((i-12)*8));
  429.   s=hexa(kd)+hexa(kc)+hexa(kb)+hexa(ka);
  430.   return s;  }
  431.  
  432.  
  433. // Given a string, set a nonce, and determine the md5 of nonce+string 
  434.  function comp_md5(avalue) {
  435.     
  436.    bvalue=avalue.value
  437.    avalue.value='Computing encryption-key '
  438.    timea=new Date()
  439.    nonce=Date.parse(timea)
  440.    avalue.form.nonce.value=nonce
  441.    aggx=nonce + bvalue
  442.    zbb=aggx.toUpperCase()
  443.    themd5=MD5(zbb)
  444.    themd5=themd5.toUpperCase()
  445.    avalue.form.verify.value=themd5.substring(0,16)
  446.    avalue.value='Encryption-key has been computed '
  447.    return true
  448.  }
  449.  
  450.  
  451. /* --------------------------- */
  452. // Random number generator
  453. function random3()
  454. ix=(171*ix)%30269
  455. iy=(172*iy)%30307
  456. iz=(170*iz)%30323
  457. var arandom=(ix/30269.) + (iy/30307.)  + (iz/30323)
  458. return Math.floor((arandom % 1.0)* 255)
  459. }
  460.  
  461. /* ---------- js 1.0 charcodeat - */
  462. function cvt_it(aa)
  463. {goo=escape(aa)
  464. lk=goo.length
  465. if (lk==1)
  466.   {isa=ascii.lastIndexOf(goo);  }
  467. else
  468. { t1=goo.substring(1,lk)
  469.   isa=hextodec(t1,lk-1)
  470. }
  471. //alert(aa+' '+isa)
  472. return isa
  473. }
  474.  
  475.  
  476. /* ********************************** */
  477. // Encrypt a form element, using md5 hash -- store in saveto.value
  478. function do_encrypt(stuff,saveto) {
  479. // document.askmd5.status.value='Computing MD5 encryption key'
  480. // document.askmd5.status.value='MD5 key computed! '
  481. // themd5=comp_md5(pwd,1) 
  482.  
  483. if (themd5=="0")
  484. { alert(' You must first enter your shared-secret password! ')
  485.   return 0
  486. }
  487.  
  488. // Note: each element uses the same sequence of random numbers. This
  489. //   does mean repetition of the sequence if more then one variable
  490. //   is encrypted (which slightly weakens encryption)
  491.  
  492.  var cx=themd5.substring(29,32)
  493.  ix=hextodec(cx,3)
  494.  var cy=themd5.substring(26,29)
  495.  iy=hextodec(cy,3)
  496.  var cz=themd5.substring(24,26)
  497.  iz=hextodec(cz,2)
  498. //alert('rnds: '+ix+' '+iy+' '+iz)
  499.  
  500.  damessage=''              // use a random # stream to decrypt
  501.  for (ii=0; ii<stuff.length ;ii++) {
  502.     iavar=cvt_it(stuff.charAt(ii))
  503. //    iavar=stuff.charCodeAt(ii)
  504.     rr=random3()
  505. //alert(ii+' '+rr)
  506.     rr2=iavar^rr
  507.     newch=hexa(rr2)
  508.     newch2=newch.substring(6,8)
  509.     damessage=damessage + newch2
  510.   } 
  511.   saveto.value=damessage
  512.   return true
  513. }
  514.  
  515.  
  516. // clear elements of the form. Typically used to clear an element
  517. //   after it's been encrypted.  The notion is to save the 
  518. //   encrypted value to a hidden element, and then clear this "raw, unencrypted
  519. //   value" just prior to submitting the form. 
  520. function clear_fields() {
  521.  for (k=0 ; k<arguments.length ; k++)
  522.    {arguments[k].value=0}
  523.  return true
  524. }
  525.  
  526.  // -->
  527.  </SCRIPT>
  528.  
  529.  
  530.