Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
DCing algorithm
#12
(01-14-2009, 08:23 PM)Lord Silva Wrote:  
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;
                    }
                    text += (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 ;) ).

C# version that only returns gibberish for me on both b+ and b-, any idea why?

Code:
public class ReadFile
    {
        public static string main(String FileName)
        {
            string text = "";
            StreamReader finp = new StreamReader(FileName);
            int counta = 0;
            int countTo123 = 0;
            byte b;
            byte d;
            while (finp.Peek() >= 0)
            {
                countTo123++;
                b = (byte)finp.Read();
                if (countTo123 > 123)
                {

                    d = DecryptByte(counta, b);
                    counta++;
                    if (counta > 36)
                    {
                        counta = 0;
                    }
                    text += (char)d;
                }
            }
            finp.Close();
            return text;
        }

        public static byte DecryptByte(int counta, byte b)
        {
            String plainEncryptionKey = "odBearBecauseHeIsVeryGoodSiuHungIsAGo";
            b -= (byte)plainEncryptionKey[counta];
            return b;
        }
    }
Reply
Thanks given by:


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)