0

I try to it. it still have junk char on it. The thing I try to do is decrypt byte key that w/o using the key. When i test is show me a junk when this code is detele any char that over the 0 to 127 but it not in english.

try
            {
                FileInputStream input = new FileInputStream (filename);
                FileOutputStream output = new FileOutputStream  (filename + ".decrypted");
                int reading;

                System.out.println("Please wait while the file being decrypted");
                Thread.sleep(1500);
                while ((reading = input.read()) != -1)
                {
                     for(int index = 0 ; index < 256; index++)
                     {
                         byte convindex = (byte) index;
                         byte test = (byte) (convindex + reading); 
                        // System.out.println (test);
                         isValidText (test);
                         if (isValidText (test))
                         {
                             output.write (index);
                             output.write (test);
                             break;
                         }
                         System.out.println ("We are done! with 1 for");

                         return; 
                     }
                     public static boolean isValidText (byte test)
        {

            if (test > 0 && test < 127)
            {
                System.out.println (test);
                return true;
            }
            System.out.println ("Hey this false" + test);

            return false;
        }
2
Contributors
1
Reply
11
Views
2 Years
Discussion Span
Last Post by Slavi
0

He pm'd that he thinks isValidText doesn't work, I tried this, works good for me

public class Test{

public static void main(String[] args){
    String s = "Ø";
    byte[] b = s.getBytes();
    System.out.println(isValidText(b));
}


public static boolean isValidText (byte[] test)
        {
            if (test[0] > 0 && test[0] < 127)
            {
                System.out.println (test);
                return true;
            }
            System.out.println ("Hey this false" + test);
            return false;
        }

}

result was

Hey this false[B@1db9742
false
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.