From 2b957ba838085550d5b003f19892d204f83343ab Mon Sep 17 00:00:00 2001 From: "youhong.ai" Date: Tue, 11 Jul 2023 14:53:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=BE=93=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../util/CompressPictureUtil.java | 2 +- src/main/java/ln/LNParse.java | 88 ------------------- src/test/java/BuilderPackageEcology.java | 8 +- .../ai/utiltest/ImageComperssorTest.java | 33 +++++++ .../youhong/ai/utiltest/ImageCompressor.java | 2 + 5 files changed, 42 insertions(+), 91 deletions(-) delete mode 100644 src/main/java/ln/LNParse.java create mode 100644 src/test/java/youhong/ai/utiltest/ImageComperssorTest.java diff --git a/src/main/java/com/customization/youhong/taibao/compresspicture/util/CompressPictureUtil.java b/src/main/java/com/customization/youhong/taibao/compresspicture/util/CompressPictureUtil.java index abee6a0..dfdc4a5 100644 --- a/src/main/java/com/customization/youhong/taibao/compresspicture/util/CompressPictureUtil.java +++ b/src/main/java/com/customization/youhong/taibao/compresspicture/util/CompressPictureUtil.java @@ -51,7 +51,7 @@ public class CompressPictureUtil { return compressPNG(image, quality); } else if ("jpeg".equalsIgnoreCase(formatName)) { return compressJPEG(image, quality); - } else if ("bmp".equalsIgnoreCase(fileName)) { + } else if ("bmp".equalsIgnoreCase(formatName)) { return compressBMP(image, quality); } else { return null; diff --git a/src/main/java/ln/LNParse.java b/src/main/java/ln/LNParse.java deleted file mode 100644 index dcf9993..0000000 --- a/src/main/java/ln/LNParse.java +++ /dev/null @@ -1,88 +0,0 @@ -// -// Source code recreated from a .class file by IntelliJ IDEA -// (powered by FernFlower decompiler) -// - -package ln; - -import org.apache.commons.codec.binary.Base64; -import org.json.JSONObject; - -import java.security.InvalidKeyException; - -public class LNParse { - public LNParse() { - } - - public LNBean getLNBean(String licensefilepath, String key) throws Exception { - byte[] licenseFile = Zip.getZipSomeByte(licensefilepath, "license"); - byte[] publicKey = Zip.getZipSomeByte(licensefilepath, "publicKey"); - byte[] licenseEncryptKey = Zip.getZipSomeByte(licensefilepath, "licenseEncryptKey"); - byte[] licenseFile2 = Zip.getZipSomeByte(licensefilepath, "license2"); - String realPublicKey = ""; - if ("emessage2".equals(key)) { - realPublicKey = "MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAIJWRm0eoQNEgZB9aUlM1PoT0N7cKCBCfkecycpeKeg57e73Fcj4ik9uYrGB01t38ut45iHJi8TLoeORYuUAhWUCAwEAAQ=="; - } else if (!"ecology7".equals(key) && !"ecology8".equals(key)) { - if ("ecology9".equals(key)) { - realPublicKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAyC90YpaWPbLaQwqt3TYlRqYC+gDTivXiVU2ZnL+tVop7tm1Ss8gnXnkd1I0jr2ffQK6m4HIGdz4lyxOfJVuT9hwtDpnflxK5fBIpc6N5iB3bZkes3XMJTyXY+afvh7vKf9yW0p1ZgQkMp7Ty4nRNQ1H/JV7RIUohEM24udiZNZySLpIYeAxTl8gR/EKL/YCIxBQfFEyQtijB0+X6Sfd/CWgNGVPuPr8V5nUZm8vXIszWBSPamD/yfvwNI9PAOII7OBNMXOC9BFAjTdCKkxdRS4ovu2V9STxAu0P8hhTnH0/zpxi4VOn32povh4f5J7x5eV+vSaN5G1G1zVPs5lc62QIDAQAB"; - } - } else { - realPublicKey = "MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBALUgEZ7eGZmJJM/3Ajj5Zdd2MG1ZONVybJV+v+jQT+csNWBBqxosLVlWvwaod1ix8Gg9GsyRJgoTs1Mg25raZcsCAwEAAQ=="; - } - - String publicKeyStr = new String(Base64.encodeBase64(publicKey)); - if (!realPublicKey.equals(publicKeyStr)) { - throw new Exception("license error!"); - } else { - JSONObject jsonLicense; - try { - byte[] licenseKey = RSACoder.decryptByPublicKey(licenseEncryptKey, publicKey); - jsonLicense = new JSONObject(new String(DESCoder.decrypt(licenseFile, licenseKey), "GBK")); - } catch (InvalidKeyException var15) { - var15.printStackTrace(); - byte[] licenseInfo2 = DESCoder.decrypt(licenseFile2, key.getBytes()); - jsonLicense = new JSONObject(new String(licenseInfo2)); - } - - LNBean lnb = new LNBean(); - lnb.setCompanyname(jsonLicense.getString("companyname")); - lnb.setLicensecode(jsonLicense.getString("licensecode")); - lnb.setHrmnum(jsonLicense.getString("hrmnum")); - // lnb.setExpiredate(jsonLicense.getString("expiredate")); - lnb.setExpiredate("2222-12-31"); - lnb.setConcurrentFlag(jsonLicense.getString("concurrentFlag")); - lnb.setLicense(jsonLicense.getString("license")); - - try { - lnb.setCid(jsonLicense.getString("cid")); - } catch (Exception var14) { - System.out.println(var14); - } - - try { - lnb.setScType(jsonLicense.getString("scType")); - } catch (Exception var13) { - System.out.println(var13); - } - - try { - lnb.setScCount(jsonLicense.getString("scCount")); - } catch (Exception var12) { - System.out.println(var12); - } - - return lnb; - } - } - - public boolean checkLicesne(LNBean lnb) { - boolean returnValue = false; - String src = lnb.getCompanyname() + lnb.getLicensecode() + "ALL" + lnb.getHrmnum() + lnb.getExpiredate() + lnb.getConcurrentFlag(); - MD5 md5 = new MD5(); - if (lnb.getLicense().equals(md5.getMD5ofStr(src))) { - returnValue = true; - } - - return returnValue; - } -} diff --git a/src/test/java/BuilderPackageEcology.java b/src/test/java/BuilderPackageEcology.java index 53a71b5..fc9c4e8 100644 --- a/src/test/java/BuilderPackageEcology.java +++ b/src/test/java/BuilderPackageEcology.java @@ -7,6 +7,9 @@ import javafx.application.Application; import javafx.geometry.Insets; import javafx.geometry.Pos; import javafx.scene.Scene; +import javafx.scene.control.Button; +import javafx.scene.control.Label; +import javafx.scene.control.TextField; import javafx.scene.control.*; import javafx.scene.layout.BorderPane; import javafx.scene.layout.HBox; @@ -14,9 +17,11 @@ import javafx.scene.layout.VBox; import javafx.stage.FileChooser; import javafx.stage.Stage; +import java.awt.*; import java.io.File; import java.io.IOException; import java.text.SimpleDateFormat; +import java.util.List; import java.util.*; public class BuilderPackageEcology extends Application { @@ -119,8 +124,7 @@ public class BuilderPackageEcology extends Application { functionNameTextField.setText(""); showSuccessAlert("升级包制作成功!"); System.out.println("压缩包位置: " + outputFile.getPath()); - System.out.println(outputFile.getParentFile()); - + Desktop.getDesktop().open(outputFile.getParentFile()); } catch (IOException e) { throw new RuntimeException(e); } diff --git a/src/test/java/youhong/ai/utiltest/ImageComperssorTest.java b/src/test/java/youhong/ai/utiltest/ImageComperssorTest.java new file mode 100644 index 0000000..3b4f869 --- /dev/null +++ b/src/test/java/youhong/ai/utiltest/ImageComperssorTest.java @@ -0,0 +1,33 @@ +package youhong.ai.utiltest; + +import basetest.BaseTest; +import com.customization.youhong.taibao.compresspicture.util.CompressPictureUtil; +import org.junit.Test; + +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; + +/** + *

图片压缩测试

+ * + *

create: 2023/7/11 14:40

+ * + * @author youHong.ai + */ +public class ImageComperssorTest extends BaseTest { + + + @Test + public void testee() throws IOException { + InputStream inputStream = CompressPictureUtil.compressImage(new FileInputStream("/Users/aoey.oct.22/Downloads/消息提醒异常.bmp"), "消息异常提醒.bmp", 0.5F); + FileOutputStream fos = new FileOutputStream("/Users/aoey.oct.22/Downloads/消息提醒异常-1.bmp"); + byte[] b = new byte[1024]; + while ((inputStream.read(b)) != -1) { + fos.write(b);// 写入数据 + } + inputStream.close(); + fos.close();// 保存数据 + } +} diff --git a/src/test/java/youhong/ai/utiltest/ImageCompressor.java b/src/test/java/youhong/ai/utiltest/ImageCompressor.java index a3accb0..9f3ff3e 100644 --- a/src/test/java/youhong/ai/utiltest/ImageCompressor.java +++ b/src/test/java/youhong/ai/utiltest/ImageCompressor.java @@ -172,6 +172,8 @@ public class ImageCompressor { // } // } } + + }