⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cipheroutputstream.java

📁 纯java AES实现
💻 JAVA
字号:
package com.jrijndael.io;import java.io.*;import com.jrijndael.JRijndael;public class CipherOutputStream {        //The underlying BufferedOutputStream instance    private BufferedOutputStream bos;        //The underlying block cipher instance    private JRijndael algorithm;        /** Creates a new instance of CipherOutputStream */    public CipherOutputStream(FileOutputStream fos, String passphrase, int keylength) {        //Create a new instance of the BufferedOutputStream        bos = new BufferedOutputStream(fos);                //Create a new instance of the block cipher        algorithm = new JRijndael();                //Initialize the block cipher        algorithm.generateKey(passphrase, keylength);    }        /** Encrypts then writes a byte array to the BufferedOutputStream */    public void write(byte[] b) throws IOException {        //Encrypt the supplyed byte array        byte[] cipherText = algorithm.encryptByteArray(b);                //Write the encrypted bytes to the BufferedOutputStream        bos.write(cipherText);    }        /** Flushes the BufferedOutputStream */    public void flush() throws IOException {        //Flush the BufferedOutputStream        bos.flush();    }        /** Clears the cipher, then closes the BufferedOutputStream */    public void close() throws IOException {        //Clear the block cipher        algorithm.clear();                //Close the BufferedOutputStream        bos.close();    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -