need help regarding the file..

View: New views
1 Messages — Rating Filter:   Alert me  

need help regarding the file..

by satish.napster :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

hi guys ....
i am working in a licencing issue for a product....
For that first i am encrypting the string and storing that in to a file in string format. next time when i am trying to fetch that data..The byte length of the fetched data is not same with the data i write to the file... so i am not able to decrypt the information..... The piece of code i am writing bellow. Pls help me its urgent

//program/....
 /**
   * This method is used to store the license key in to the file system.
   *
   * It takes the Licence key as argument
   */
  public void storeLicense(String licenseKey) throws Exception {
         
          BufferedWriter out = new BufferedWriter(new FileWriter(filePath, true));
         
          AnalyticaCryptography anaCrypt = new AnalyticaCryptography();
         
          byte[] byteLicenseKey = licenseKey.getBytes();
         
          byte[] encryptedLicense = anaCrypt.encrypt(byteLicenseKey);
     
          out.write(new String(encryptedLicense));
          System.out.println("Length:"+encryptedLicense.length);
          out.newLine();
     
      out.close();
  }
 
  /**
   * This method is used to retrive License keys from the file system
   * algorithm.
   *
   */
  public String retriveLicense() throws Exception {
          BufferedReader in = new BufferedReader(new FileReader(filePath));
         
          AnalyticaCryptography anaCrypt = new AnalyticaCryptography();
          String inLine = null;

      while ((inLine = in.readLine()) != null) {
      System.out.println(inLine.getBytes().length);
      System.out.println(inLine);
      //byte[] encryptedLicense = anaCrypt.decrypt(inLine.getBytes());
      }
         
         
          //byte[] encryptedLicense = anaCrypt.encrypt(inLine.getBytes());
     
          in.close();
          return "success";
  }
LightInTheBox - Buy quality products at wholesale price