Skip to main content

Java (Non-MapReduce)

This section describes how a non-MapReduce Java program can use the DgDecrypter API.

Configuration

  1. Create a Java project through IDE or Command Line

  2. Add the following jars to the project classpath.

    1. bcpg-jdk15on-150.jar

    2. bcprov-ext-jdk15on-150.jar

    3. commons-codec-1.7.jar

    4. guava-13.0.1.jar

    5. hadoop-common-0.22.0.jar

    6. DgDecrypter.jar

      *These jars will be available from PKWARE.

  3. We provide two ways to use the API: decryptString method, decryptStringStatic method.
    Usage Sample

    1. decryptString function

      CODE
      import java.io.BufferedReader;
      import java.io.FileReader;
      import java.io.IOException;
      import com.dataguise.decrypterlib.java.decrypter.GenerateConfParams;
      import com.dataguise.decrypterlib.java.decrypter.Decrypter;
      
      //Example of decrypting a file line by line
      public class DecryptFile {
      
      public static void main(String[] args) throws IOException{
      //Generate parameters(ACL, Keys, User)
      String params = GenerateConfParams.generateParams();
      Decrypter de = new Decrypter(params);
          	//Input file path in the local file system
      String file = "C:/Enterprise_2011/JavaDecryption/StructuredData-I.txt";
       
          //Read the file
          BufferedReader br = new BufferedReader(new FileReader(file));
          String line;
          while ((line = br.readLine()) != null) 
      {
              //Decrypt each line
              String output = de.decryptString(line);
              System.out.println(output);
          			}
      br.close();
      }
    2. decryptStringStatic function

      CODE
      import java.io.BufferedReader;
      import java.io.FileReader;
      import java.io.IOException;
      import com.dataguise.decrypterlib.java.decrypter.GenerateConfParams;
      import com.dataguise.decrypterlib.java.decrypter.Decrypter;
      
      //Example of decrypting a file line by line
      public class DecryptFile {
      
      public static void main(String[] args) throws IOException{
          //Generate parameters(ACL, Keys, User)
          String params = GenerateConfParams.generateParams();
          Decrypter.setParams(params);
          //Input file path in the local file system
      String file = "C:/Enterprise_2011/JavaDecryption/StructuredData-I.txt";
       
          	//Read the file
      BufferedReader br = new BufferedReader(new FileReader(file));
          String line;
          while ((line = br.readLine()) != null) 
      {
      //Decrypt each line
      String output = Decrypter.decryptStringStatic(line);
           System.out.println(output);
         			}
      br.close();
      }	

In the above code, Decrypter.decryptString will only decrypt those sensitive items in the line variable for which the user executing the program has ACL rights.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.