Hello, I think the code below will simply help you for encrypting the password:
Code:
import java.io. *;
Public class testing
{
Public testing(int one)
{
key = one;
}
Public void encryptFile(InputFileName String, String outputFileName) throws IOException
{
InputStream IStream = null;
OutputStream oStream= null;
try
{
IStream = new FileInputStream(InputFileName);
oStream= new FileOutputStream(outputFileName);
encryptStream(IStream, out);
}
finally
{
if(IStream! = null)
IStream.close();
if(out! = null)
out.close();
}
}
Public void encryptStream(InputStream IStream, OutputStream out) throws IOException
{
boolean done = false;
while(! done)
{
int next = IStream.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;
}
Bookmarks