|
@@ -33,12 +33,6 @@ public class EncryptionTest {
|
|
|
}
|
|
|
|
|
|
|
|
|
- public static void main(String[] args) {
|
|
|
- String a = "aLI5iXza3R/w7aJ2AsYhUT7EGS0Zqk94k1nXK9rT8AvJGMbMUJytae53f82pFphWy0bmnEGv4fWb6RcpE9m3tQ==";
|
|
|
- String s = AesEncodeUtil.aesDecode(a, "EC/Z+S7c3EFJa2dtvLyekg==");
|
|
|
- System.out.println(s);
|
|
|
- }
|
|
|
-
|
|
|
|
|
|
|
|
|
|
|
@@ -63,35 +57,45 @@ public class EncryptionTest {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ public static void main(String[] args) {
|
|
|
+ String key = "EC/Z+S7c3EFJa2dtvLyekg==";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ String content = readToString("D:\\whole.txt");
|
|
|
+ String decodeStr = AesEncodeUtil.aesDecode(content, key);
|
|
|
+ System.out.println(decodeStr);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
|
|
|
* 读取文件
|
|
|
*
|
|
|
* @param fileName
|
|
|
* @return
|
|
|
*/
|
|
|
- public static String readToString(String fileName) {
|
|
|
+ private static String readToString(String fileName) {
|
|
|
String encoding = "UTF-8";
|
|
|
File file = new File(fileName);
|
|
|
- Long filelength = file.length();
|
|
|
- byte[] filecontent = new byte[filelength.intValue()];
|
|
|
+ Long fileLength = file.length();
|
|
|
+ byte[] fileContent = new byte[fileLength.intValue()];
|
|
|
FileInputStream in = null;
|
|
|
try {
|
|
|
in = new FileInputStream(file);
|
|
|
- in.read(filecontent);
|
|
|
- } catch (FileNotFoundException e) {
|
|
|
- throw new BusinessException(404,"文件不存在");
|
|
|
- } catch (IOException e) {
|
|
|
- throw new BusinessException(404,"文件io不存在");
|
|
|
+ in.read(fileContent);
|
|
|
+ } catch (Exception e) {
|
|
|
+ System.out.println(e);
|
|
|
}finally {
|
|
|
try {
|
|
|
in.close();
|
|
|
} catch (IOException e) {
|
|
|
- throw new BusinessException(404 , "io流关闭异常");
|
|
|
+ System.out.println(e);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
try {
|
|
|
- return new String(filecontent, encoding);
|
|
|
+ return new String(fileContent, encoding);
|
|
|
} catch (UnsupportedEncodingException e) {
|
|
|
System.err.println("The OS does not support " + encoding);
|
|
|
e.printStackTrace();
|