📄 cryptoinputstream.java
字号:
package ecc.io;import java.io.*;import ecc.*;public class CryptoInputStream extends InputStream { private DataInputStream in; private CryptoSystem cs; private Key key; private byte[] buffer; private int top; private int blocksize; public CryptoInputStream(InputStream in, CryptoSystem cs, Key key) { this.in = new DataInputStream(in); this.cs = cs; this.key = key; buffer = new byte[0]; } public int read() throws IOException { if(top == buffer.length) { try { blocksize = in.readInt(); } catch (EOFException e) { return -1; } byte[] cipher = new byte[blocksize]; in.read(cipher); buffer = cs.decrypt(cipher, key); top = 0; } top++; return buffer[top-1]; } public void close() throws IOException { in.close(); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -