Little Fighter Empire - Forums
DCing algorithm - Printable Version

+- Little Fighter Empire - Forums (https://lf-empire.de/forum)
+-- Forum: Little Fighter 2 Zone (https://lf-empire.de/forum/forumdisplay.php?fid=7)
+--- Forum: Projects (https://lf-empire.de/forum/forumdisplay.php?fid=10)
+---- Forum: Releases (https://lf-empire.de/forum/forumdisplay.php?fid=34)
+---- Thread: DCing algorithm (/showthread.php?tid=1877)

Pages: 1 2 3


DCing algorithm - Silverthorn - 01-14-2009

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;
   }
      
}



RE: DCing algorithm - Boop - 01-14-2009

Code:
/*Programmed by Silva
Stolen stuff from Blue Phoenix
Latest version: 14 Jan 2009
*/

   import java.io.*;

    public class ReadFile{
       public static void main(String[] args) throws IOException{
         File f;
         f=new File("template.dat");// file rawr
          
         if(!f.exists()&& f.length()<0)
            System.out.println("The specified file is not exist");
        
         else{
            FileInputStream finp=new FileInputStream(f);
            int counta = 0;
            int countTo123 = 0;
            byte b;
            byte d;
            do{
               countTo123++;
               b=(byte)finp.read();
               if (countTo123 > 123)
               {
              
                  d = DecryptByte(counta,b);
                  counta++;
                  if (counta > 36){
                     counta = 0;
                  }
                  System.out.print((char)d);
               }
            }
            while(b!=-1);
            finp.close();
         }
      }
      
       public static byte DecryptByte(int counta,byte b){
         String plainEncryptionKey = "odBearBecauseHeIsVeryGoodSiuHungIsAGo";
         b -= (byte)plainEncryptionKey.charAt(counta);
         return b;
      }
   }

My version :) (works faster because it uses streams ;) ).


RE: DCing algorithm - Silverthorn - 01-14-2009

k, take Silva's version, it's working faster. For a reason that I don't know =P


RE: DCing algorithm - Azriel - 01-15-2009

mine's better coz it reads and writes. not released yet coz I haven't finished it (doesn't update UI and what not). (no - colour coding is not as simple as it looks)

[Image: 2qmmc0p.png]



Azriel~



RE: DCing algorithm - Boop - 01-15-2009

We are talking about the algorithm >.<" . Not about the application, lol.


RE: DCing algorithm - 1477 - 01-15-2009

Ok, I don't know if I should be posting here (because the only people who have posted are elite members :D) but do the decoding algorithms work on R-LF2 data files? Jiquera's DC doesn't work, and Rammichael's DC works, but the only difference between regular and RLF2's data files are the special chinese characters in the name (I think everyone knows this already). My question is, why does Rammichael's DC works and Jiquera's doesn't (after all, they're just characters in the name), and does BP and Silva's algorithm work for R-LF2 data files ?


RE: DCing algorithm - Boop - 01-15-2009

Jiquera's data changer is just uses poorly coded libraries to read in data(my theory), it stops when it reaches a certain byte value. This doesn't happen with our implementations I believe.


RE: DCing algorithm - Silverthorn - 01-16-2009

I don't have any r-lf2-files on my comp right now, so I cannot test the decrypter with them. However, I just tried the "stupid" unreadable-making-method, where you just replace the first few bits. It works fine, and I think this is the encryption method of r-lf2. (Of course it works, I know how me and Silva coded :P)

But just to prevent any questions, CE-LF2 dat-files are encrypted in a different way, and with this code you cannot decrypt them either.


RE: DCing algorithm - Yakui - 01-18-2009

(01-16-2009, 03:06 PM)Blue Phoenix Wrote:  I don't have any r-lf2-files on my comp right now, so I cannot test the decrypter with them. However, I just tried the "stupid" unreadable-making-method, where you just replace the first few bits. It works fine, and I think this is the encryption method of r-lf2. (Of course it works, I know how me and Silva coded :P)

I love bringing this up, but if you press A + B + C in LF2 mid-game you get to a sort of debug mode.

F2 crashes the game, but F3 calls up an encrypter/decrypter for .dat files. I don't have an R-LF2 data file at hand, but there's a chance it was done using that or celebix' encrypter/decrypter, which does exactly the same.

Kinda what I suspect CL of having done, really, however I'm not sure how relevant this is.


RE: DCing algorithm - Kevin - 08-01-2012

DAMN YOU ALL genius people
or more like DAMN YOU java (for me it's a 'language from planet')

I've been trying many things but none of them works :(

Please try to make this noob understand how to encode/decode dat files. I'd like to start from how to convert the encoded version into a readable version. I'm learning from Silva's code, but also read BP's to help me understand. but....

1. Count to 123 first - does that mean the first 123 characters are unused? Or... I don't have any idea, probably this is what makes me fail coz I don't even have any idea what else to try about this
2. b=(byte)finp.read(); --> I can't find this on my dictionary. What does this mean in this planet's language?
3. d = DecryptByte(counta,b); ---> does DecryptByte give you the KeyAscii (keycode or sth) from the character? But if so, I don't understand why there must be the variable 'b' behind it.
4. System.out.print((char)d); ---> does this prints the character stored in variable 'd' ? which is the result of DecryptByte(counta,b) ? But that's strange, I can't see where you modify / encode the byte :0 .

And damn you gravedigging warning :( . And damn me :( .
and thanks for replying and helping :D !!




EDIT:
Finally :D . Chiko explained all to me.
So the first 123 chars are useless.
We subtract the 'KeyAscii' of the 124th character with the 'KeyAscii' of the 1st char of the encryption key.
then the 125th character with the 2nd char from the key, so on.
When we get to the end of the encryption key, go back to the first character.

Oooooooo....... not it works, I have to open another thread