Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
DCing algorithm
#1
After Silva explained how the encryption of dat-files works (big thanks for that again), I tried to implement that into a programming language. As the only language I'm better at is Java, this code is written in Java (duh!).

Feel free to copy the code, or try to understand it. I seldomly write comments, and if I do, they're pretty useless :P

What it does: it reads the file template.dat (which has to be in the same folder as the class-object), decrypts it, and outputs the decrypted result into a txt-file.

On a side note: if you copy this code, I'd be pleased as punch if you leave the author notes in there. If you remove them, I'll stalk you until I chopped off your head after I cut out your heart, pulled out every single nail, sliced up your stomach and the usual stuff Twisted
Code:
/*
Programmed by Blue Phoenix
Explanations and help by Silva
Latest version: 14 Jan 2009
*/

import java.io.*;
import java.lang.*;

public class ReadIt {    

   public static void main(String args[]) throws IOException {
      int mod;
      char buffer;
      String finalCode = "";
      String plainEncryptionKey = "odBearBecauseHeIsVeryGoodSiuHungIsAGo";
      FileInputStream data = new FileInputStream("template.dat");
      int uselessCheck = 0;
            
      byte[] encr = new byte[plainEncryptionKey.length()];
      for (int i = 0; i < plainEncryptionKey.length(); i++)
         encr[i] = (byte)plainEncryptionKey.charAt(i);
            
      for (int i = data.read(); i != -1; i = data.read()) {
         byte encrSingle;
         if (uselessCheck >= 123) {
            buffer = (char)i;
            mod = (uselessCheck-123) % plainEncryptionKey.length();
            encrSingle = encr[mod];
            finalCode += decrypt(buffer,mod,(uselessCheck-123),encrSingle);
         }
         uselessCheck++;
      }
            
      // System.out.println(finalCode);
              
      try {
         FileOutputStream fout = new FileOutputStream ("Template.txt");
         new PrintStream(fout).println (finalCode);
         fout.close();
      }
      catch (IOException e) {
         System.err.println ("Unable to write to file");
         System.exit(-1);
      }
    
   }
    
   public static char decrypt(char buffer, int mod, int i, byte encrSingle) {
      byte datDecr;
      char decrChar;
      datDecr = (byte)buffer;
      decrChar = PatchData(i,mod,datDecr,encrSingle);
      return decrChar;
   }
        
   public static char PatchData (int i, int mod, byte datDecr, byte encrSingle){
      char result;      
      datDecr -= encrSingle;
      result = (char)datDecr;
      return result;
   }
      
}
Silverthorn / Blue Phoenix
~ Breaking LFE since 2008 ~

"Freeze, you're under vrest!" - Mark, probably.

» Gallery | » Sprites | » DeviantArt
Reply
Thanks given by: MH-Razen , zort , MangaD


Messages In This Thread
DCing algorithm - by Silverthorn - 01-14-2009, 07:33 PM
RE: DCing algorithm - by Boop - 01-14-2009, 08:23 PM
RE: DCing algorithm - by YinYin - 03-26-2015, 07:58 AM
RE: DCing algorithm - by Som1Lse - 03-26-2015, 12:40 PM
RE: DCing algorithm - by YinYin - 03-26-2015, 12:57 PM
RE: DCing algorithm - by Silverthorn - 01-14-2009, 08:26 PM
RE: DCing algorithm - by Azriel - 01-15-2009, 06:09 PM
RE: DCing algorithm - by Boop - 01-15-2009, 06:29 PM
RE: DCing algorithm - by 1477 - 01-15-2009, 09:50 PM
RE: DCing algorithm - by Boop - 01-15-2009, 11:09 PM
RE: DCing algorithm - by Silverthorn - 01-16-2009, 03:06 PM
RE: DCing algorithm - by Yakui - 01-18-2009, 09:19 PM
RE: DCing algorithm - by Kevin - 08-01-2012, 10:45 AM
RE: DCing algorithm - by Boop - 08-01-2012, 11:53 AM
RE: DCing algorithm - by A-Man - 03-26-2015, 08:11 AM
RE: DCing algorithm - by YinYin - 03-26-2015, 08:31 AM
RE: DCing algorithm - by A-Man - 03-26-2015, 02:14 PM
RE: DCing algorithm - by Dia6lo - 06-19-2015, 11:57 AM
RE: DCing algorithm - by Som1Lse - 06-19-2015, 05:14 PM
RE: DCing algorithm - by Dia6lo - 06-19-2015, 05:37 PM
RE: DCing algorithm - by Hellblazer - 06-21-2015, 10:33 AM
RE: DCing algorithm - by Zelphir - 06-13-2021, 10:38 AM
RE: DCing algorithm - by Mesujin - 08-30-2022, 03:47 PM



Users browsing this thread: 1 Guest(s)