home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / srev13h.zip / enc_test.sht < prev    next >
Text File  |  1999-04-29  |  4KB  |  120 lines

  1. <!-- This is a sample HTML document that uses the "form encryption" 
  2.      facility of SRE-http.   
  3.      To use the form encryption facility, the following steps are required:
  4.         1) Include (using an INCLUDE ssi) the ENC_FORM.RSP javascript procedures
  5.         2) specify a hidden element with name="nonce"
  6.            and a hidden element with name="verify"     
  7.         3) Using a TEXT element, get a "shared-secret" password, and then 
  8.            call comp_md5 to generate an encryption key
  9.         4) Specify some hidden elements that will contain the encrypted variables
  10.         5) Include some non-hidden form elements (such as TEXT, TEXTAREA, and SELECT), 
  11.            and encrypt their values using  do_encrypt
  12.         6) clear the raw (unencrypted) variables (that is, the raw versions
  13.            of the variables you encrypted in step 5)
  14.         7) Submit the form -- the script on the server will have to
  15.            decrypt (using SREF_FORM_DECRYPT) the encrypted
  16.            variables (that were set in 4 and 5)
  17.  
  18.  Note: in this example, the ENC_TEST.CMD  addon will read & decrypt 
  19.        enc_message1 and  enc_myvote. It will use "as is" rvisitor and yourname
  20. -->
  21.  
  22. <html>
  23. <head>
  24. <title>Test of SRE-http encryption of HTML FORMS</title>
  25.  
  26. <!-- STEP 1 : include necessary javascript procedures  -->
  27. <!-- include enc_form.rsp -->
  28.  
  29. </head>
  30.  
  31. <body>
  32. <h1>Test of SRE-http encryption of form elements </h1>
  33.  
  34. This form demonstrates SRE-http's form encryption facility.
  35.  
  36. <form action="/enc_test" name="enctest" method="GET"><p>
  37.  
  38. <!-- STEP 2: Specify name="nonce" and name="verify" hidden elements. 
  39.              The values are unimportant (they will be changed by the 
  40.              comp_md5 javascript procedure)  -->
  41. <input type="hidden" name="nonce" value=0>
  42. <input type="hidden" name="verify" value=0>
  43.  
  44. <!-- STEP 3: ask for "shared-secret" password -->
  45.  
  46. <br>What is your <tt>shared-secret</tt> password:
  47.     <input type="text" name="your_pwd" size=33 
  48.            onChange="comp_md5(this.form.your_pwd) ; return true" > 
  49.  
  50. <br>
  51.  
  52.  
  53. <!-- STEP 4: specify some hidden elements that will store encrypted values.
  54.              The values are not important, since they will be changed by
  55.              do_encrypt -->
  56.  
  57. <input type="hidden" name="enc_message1" value=0>
  58. <input type="hidden" name="enc_myvote" value=0>
  59.  
  60. <!-- ask some questions -->
  61. What is your name: <input type="text" name="yourname" size=30><br>
  62. <input type="checkbox" value="yes" name="rvisitor">Are you a regular visitor?
  63.  
  64. <p>
  65.  
  66. <!--  STEP 5: now ask some questions, whose answers will be encrypted
  67.               with do_encrypt (note that do_encrypt is called by the
  68.               onChange event handler in the SELECT and TEXTAREA elements  -->
  69.  
  70. What is your opinion on the following question:
  71.  
  72. <blockquote>Should veeblefetzers be manufactured using the frobisher process,
  73. or using the poiyut array?</blockquote>
  74.  
  75. <!-- note that encrypting SELECT is a bit trickier then other elements -->
  76.  
  77. Please select one of the following:
  78. <select name="myvote" size=4
  79.     onChange=" igoo=this.selectedIndex ;
  80.                igoo2=this.options[igoo] ;
  81.                do_encrypt(igoo2.text,this.form.enc_myvote) ;  
  82.                             return true "
  83. >
  84.   <option value="frobisher">Frobisher
  85.   <option value="poiyut">Poiyut
  86.   <option value="neither">Neither
  87.   <option value="no_opinion">No opinion
  88. </select>
  89. <p>
  90.  
  91. Please enter a comment: 
  92. <textarea name="message1" rows=4 cols=30
  93.     onChange="do_encrypt(this.value,this.form.enc_message1) ; 
  94.                          return true "
  95. ></textarea>
  96.  
  97.  
  98. <!-- STEP 6: clear elements that contain the raw (unencrypted) versions
  99.              of variables to be encrypted
  100.              Note that clearing SELECT is a bit complicated.
  101.              Also note that clearing the password is not critical, but
  102.              does avoid some problems if the client "backs up" to this form
  103.              (after submitting).
  104.  
  105.              Caution: this step must NOT be skipped -- if you skip it,
  106.                       the raw (unencrypted) values will be transmitted!
  107.                                
  108.  -->
  109.  
  110. <input type="submit" value="submit now!" 
  111.        onClick="clear_fields(this.form.myvote.options[this.form.myvote.selectedIndex],
  112.                              this.form.message1,this.form.your_pwd);
  113.                   return true ">
  114. <input type="reset">        
  115. </form>
  116.  
  117. </body>
  118. </html>
  119.  
  120.