JAVA - JSP / Jencryptor

Durum
Üzgünüz bu konu cevaplar için kapatılmıştır...
zulme karşı mukavemet!
Süper Üye
Katılım
7 Ocak 2016
Mesajlar
1,357
Çözümler
20
Tepki puanı
386
Ödüller
11
10 HİZMET YILI
PHP:
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.IOException;

/**
   [email protected]
*/
public class Encryptor
{
    
   public Encryptor(int aKey)
   {
      key = aKey;
   }

   
   public void encryptFile(String inFile, String outFile)
         throws IOException
   {
      InputStream in = null;
      OutputStream out = null;

      try
      {
         in = new FileInputStream(inFile);
         out = new FileOutputStream(outFile);
         encryptStream(in, out);
      }
      finally
      {
         if (in != null) in.close();
         if (out != null) out.close();
      }      
   }

        
   public void encryptStream(InputStream in, OutputStream out)
         throws IOException
   {
      boolean done = false;
      while (!done)
      {
         int next = in.read();
         if (next == -1) done = true;
         else
         {
            byte b = (byte) next;
            byte c = encrypt(b);
            out.write(c);
         }
      }
   }

    
   public byte encrypt(byte b)
   {
      return (byte) (b + key);
   }

   private int key;
}
 
Durum
Üzgünüz bu konu cevaplar için kapatılmıştır...
Üst