03-26-2015, 07:58 AM
(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;
}
}
Chat
