You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by mg...@apache.org on 2007/04/17 01:34:50 UTC

svn commit: r529446 - in /cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/conf: Rot13PasswordEncoder.java Rot47PasswordEncoder.java

Author: mgentry
Date: Mon Apr 16 16:34:48 2007
New Revision: 529446

URL: http://svn.apache.org/viewvc?view=rev&rev=529446
Log:
Touched up comments to better explain functionality.

Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/conf/Rot13PasswordEncoder.java
    cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/conf/Rot47PasswordEncoder.java

Modified: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/conf/Rot13PasswordEncoder.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/conf/Rot13PasswordEncoder.java?view=diff&rev=529446&r1=529445&r2=529446
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/conf/Rot13PasswordEncoder.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/conf/Rot13PasswordEncoder.java Mon Apr 16 16:34:48 2007
@@ -74,9 +74,9 @@
 
       // If c is a letter, rotate it by 13.  Numbers/symbols are untouched.
       if ((c >= 'a' && c <= 'm') || (c >= 'A' && c <= 'M'))
-        c += 13;
+        c += 13; // The first half of the alphabet goes forward 13 letters
       else if ((c >= 'n' && c <= 'z') || (c >= 'A' && c <= 'Z'))
-        c -= 13;
+        c -= 13; // The last half of the alphabet goes backward 13 letters
 
       result.append(c);
     }
@@ -84,6 +84,14 @@
     return result.toString();
   }
 
+  /**
+   * Small test program to run text through the ROT-13 cipher.  This program
+   * can also be run by hand to encode/decode values manually.  The values
+   * passed on the command line are printed to standard out.
+   *   
+   * @param args The array of text values (on the command-line) to be run
+   *             through the ROT-13 cipher.
+   */
   public static void main(String[] args) 
   {
     Rot13PasswordEncoder encoder = new Rot13PasswordEncoder();

Modified: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/conf/Rot47PasswordEncoder.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/conf/Rot47PasswordEncoder.java?view=diff&rev=529446&r1=529445&r2=529446
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/conf/Rot47PasswordEncoder.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/conf/Rot47PasswordEncoder.java Mon Apr 16 16:34:48 2007
@@ -70,7 +70,7 @@
     {
       char c = value.charAt(i);
 
-      // Process letters, numbers, and symbols -- ignore spaces
+      // Process letters, numbers, and symbols -- ignore spaces.
       if (c != ' ')
       {
         // Add 47 (it is ROT-47, after all).
@@ -79,7 +79,10 @@
         // If character is now above printable range, make it printable.
         // Range of printable characters is ! (33) to ~ (126).  A value
         // of 127 (just above ~) would therefore get rotated down to a
-        // 33 (the !).
+        // 33 (the !).  The value 94 comes from 127 - 33 = 94, which is
+        // therefore the value that needs to be subtracted from the
+        // non-printable character to put it into the correct printable
+        // range.
         if (c > '~')
           c -= 94;
       }
@@ -90,6 +93,14 @@
     return result.toString();
   }
 
+  /**
+   * Small test program to run text through the ROT-47 cipher.  This program
+   * can also be run by hand to encode/decode values manually.  The values
+   * passed on the command line are printed to standard out.
+   *   
+   * @param args The array of text values (on the command-line) to be run
+   *             through the ROT-47 cipher.
+   */
   public static void main(String[] args) 
   {
     Rot47PasswordEncoder encoder = new Rot47PasswordEncoder();