?? input_output.java
字號:
package SimpleRSA;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
public class Input_Output
{
static int[] Input_Plain(String args)
{
int[] temp = null;
try
{
File file = new File(args);
byte[] bt = new byte[(int)file.length()];
FileInputStream in = new FileInputStream(file);
in.read(bt);
temp = new int[bt.length];
for(int i=0;i<bt.length;i++)
temp[i] = bt[i] + 128;
in.close();
}
catch (IOException e)
{
System.out.println("IO Errors: 1");
}
return temp;
}
static int[] Input_Cipher(String args)
{
StringBuffer s = new StringBuffer();
try
{
FileInputStream in = new FileInputStream(new File(args));
while(in.available()>0)
{
s.append((char)in.read());
}
in.close();
}
catch (IOException e)
{
System.out.println("IO Errors: 2");
}
int Cipher[] = new int[s.length()/3];
for(int i=0;i<Cipher.length;i++)
{
Cipher[i] = Integer.parseInt(s.substring(i*3, (i+1)*3));
}
return Cipher;
}
static String Input_Key(String args)
{
String keyString = "";
try
{
FileInputStream in = new FileInputStream(new File(args));
while(in.available()>0)
{
keyString += (char)in.read();
}
in.close();
}
catch (IOException e)
{
System.out.println("IO Errors: 3");
}
return keyString;
}
static byte[] Input_PlainForSign(String args)
{
byte[] bt =null;
try
{
File file = new File(args);
bt = new byte[(int)file.length()];
FileInputStream in = new FileInputStream(file);
in.read(bt);
in.close();
}
catch(IOException e)
{
System.out.println("IO Errors: 7");
}
return bt;
}
static void Output_Cipher(String args,String s)
{
try
{
File file = new File(args);
FileOutputStream out = new FileOutputStream(file);
byte b[] = new byte[s.length()];
b=s.getBytes();
out.write(b);
}
catch (IOException e)
{
System.out.println("IO Errors: 4");
}
}
static void Output_Plain(String args,byte[] plain)
{
File file = new File(args);
FileOutputStream out;
try
{
out = new FileOutputStream(file);
out.write(plain);
}
catch (IOException e)
{
System.out.println("IO errors: 5");
}
}
static void Output_Key(String args,int[] key)
{
File file = new File(args);
String s = "";
if(key.length == 2)
{
s = s + "modular: " + key[0] + (char)13 + (char)10;
s = s + "public key: " + key[1];
}
else
{
s = s + "modular: " + key[0] + (char)13 + (char)10;
s = s + "public key: " + key[1] + (char)13 + (char)10;
s = s + "private key: " + key[2];
}
try
{
FileOutputStream out = new FileOutputStream(file);
byte b[] = new byte[s.length()];
b=s.getBytes();
out.write(b);
}
catch (IOException e)
{
System.out.println("IO Errors: 6");
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -