?? symmetryencrypt.java
字號:
package com.gmc.crypto;
import java.io.File;
import java.io.InputStream;
import java.security.Key;
import com.gmc.encrypt.Encryption;
/**
* 對稱加密算法的公用接口,實現對稱加密算法的加解密功能
* @author Wanna
*
*/
public interface SymmetryEncrypt extends Encryption
{
/**
* 對文件進行加密處理
* @param file 要加密的文件
* @param key 加密操作的密鑰
* @return 存有密文信息的文件 ,file路徑下擴展名為.djm的文件
* 例file F:\1.txt
* 密文 F:\1.txt.djm
* @throws Exception
*/
public File encrypt(File file, Key key) throws Exception;
/**
* 對輸入流中的數據進行加密
* @param plainText 存有加密數據的輸入流
* @param key 加密密鑰
* @param cipherPath 加密后的,存放密文信息的文件所在路徑
* @return 指定路徑下的,存有密文信息的文件
* @throws Exception
*/
public File encrypt(InputStream plainText,Key key,String cipherPath) throws Exception;
/**
* 解密
* @param cipherText 密文
* @param key 解密密鑰
* @return 以字符串形式返回明文信息
* @throws Exception
*/
public String decrypt(byte[] cipherText, Key key) throws Exception;
/**
* 解密
* @param cipherText 密文信息
* @param key 解密密鑰
* @return 以字符串形式返回明文信息
* @throws Exception
*/
public String decrypt(String cipherText, Key key) throws Exception;
/**
* 解密,對擴展名為.djm的密文文件進行解密操作
* @param cipherFile 明文
* @param key 解密密鑰
* @return 存有明文信息的文件
* 例: 密文文件 F:\1.txt.djm
* 返回: F:\1.txt
* @throws Exception
*/
public File decrypt(File cipherFile, Key key) throws Exception;
/**
* 解密
* @param cipherText 存有密文件信息的輸入流
* @param key 解密密鑰
* @param plainPath 解密后,將明文信息存放在此路徑下
* @return 存有明文信息的文件
* @throws Exception
*/
public File decrypt(InputStream cipherText, Key key,String plainPath) throws Exception;
/**
* 獲得加密/解密操作所使用的密鑰Key
* @return 加/解密密鑰Key
* @throws Exception
*/
public Key getKey() throws Exception;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -