diff --git a/Readme.md b/Readme.md index d847ffa..d52d261 100644 --- a/Readme.md +++ b/Readme.md @@ -10,7 +10,10 @@ The ENC decryption tool, which can decrypt configuration files using getAllDecryptType(){ - return Arrays.stream(SecurityMethod.values()).map(SecurityMethod::decryptType).collect(Collectors.toSet()); - } - - public static List getAllDecryptInformation(){ - return Arrays.stream(SecurityMethod.values()).map(SecurityMethod::decryptInformation).collect(Collectors.toList()); + public static Map> getType2Information(){ + Map> result = new HashMap<>(); + for (SecurityMethod value : SecurityMethod.values()) { + if(result.containsKey(value.decryptType())){ + result.get(value.decryptType()).add(value.decryptInformation()); + }else{ + result.put(value.decryptType(), Lists.newArrayList(value.decryptInformation())); + } + } + return result; } } diff --git a/src/main/java/tech/shiker/config/EncSettingState.java b/src/main/java/tech/shiker/config/EncSettingState.java index f466ab1..bc3269b 100644 --- a/src/main/java/tech/shiker/config/EncSettingState.java +++ b/src/main/java/tech/shiker/config/EncSettingState.java @@ -18,6 +18,7 @@ public final class EncSettingState implements PersistentStateComponent decryptedInformationBox = new ComboBox<>(); private String decryptedInformation = "AES/ECB/PKCS5Padding"; private final JBTextField decryptedIv = new JBTextField(); + private final JRadioButton isHtmlView = new JRadioButton("On"); ; public EncToolComponent() { - SecurityMethod.getAllDecryptType().forEach(decryptedTypeBox::addItem); - SecurityMethod.getAllDecryptInformation().forEach(decryptedInformationBox::addItem);decryptedTypeBox.addActionListener(e -> decryptedType = (String) decryptedTypeBox.getSelectedItem()); - decryptedInformationBox.addActionListener(e -> decryptedInformation = (String) decryptedInformationBox.getSelectedItem()); + JLabel decryptedIvLabel = new JBLabel("Enter decrypted iv:"); + SecurityMethod.getType2Information().keySet().forEach(decryptedTypeBox::addItem); + decryptedTypeBox.addActionListener(e -> { + decryptedType = (String) decryptedTypeBox.getSelectedItem(); + updateInformationComboBox(decryptedType, decryptedInformationBox); + }); + decryptedInformationBox.addActionListener(e -> { + decryptedInformation = (String) decryptedInformationBox.getSelectedItem(); + updateDecryptedVi(decryptedIv, decryptedIvLabel, decryptedInformation); + }); + isHtmlView.addActionListener(e -> { + if (isHtmlView.isSelected()) { + isHtmlView.setText("On"); + } else { + isHtmlView.setText("Off"); + } + }); myMainPanel = FormBuilder.createFormBuilder() + .addLabeledComponent(new JBLabel("Html compare view:"), isHtmlView, 1, false) .addLabeledComponent(new JBLabel("Enter decrypted type: "), decryptedTypeBox, 1, false) - .addLabeledComponent(new JBLabel("Enter decrypted key:"), decryptedKeyText, 1, false) .addLabeledComponent(new JBLabel("Enter decrypted information:"), decryptedInformationBox, 1, false) - .addLabeledComponent(new JBLabel("Enter decrypted iv:"), decryptedIv, 1,false) + .addLabeledComponent(new JBLabel("Enter decrypted key:"), decryptedKeyText, 1, false) + .addLabeledComponent(decryptedIvLabel, decryptedIv, 1, false) .addComponentFillVertically(new JPanel(), 0) .getPanel(); } + private void updateDecryptedVi(JBTextField decryptedIv, JLabel decryptedIvLabel, String decryptedInformation) { + // 根据解密信息的不同,更新IV的可见性 + if (decryptedInformation != null && decryptedInformation.contains("CBC")) { + decryptedIv.setVisible(true); + decryptedIvLabel.setVisible(true); + }else{ + decryptedIv.setVisible(false); + decryptedIvLabel.setVisible(false); + } + } + + // 更新城市ComboBox的内容 + private void updateInformationComboBox(String decryptedType, ComboBox decryptedInformationBox) { + String[] cities = SecurityMethod.getType2Information().get(decryptedType).toArray(new String[0]); + decryptedInformationBox.setModel(new DefaultComboBoxModel<>(cities)); + } + public JPanel getPanel() { return myMainPanel; } @@ -61,19 +98,27 @@ public String getDecryptedIv() { return decryptedIv.getText(); } - public void setDecryptedTypeText(@NotNull String decryptedType){ + public String getIsHtmlView() { + return isHtmlView.getText(); + } + + public void setDecryptedTypeText(@NotNull String decryptedType) { decryptedTypeBox.setSelectedItem(decryptedType); } - public void setDecryptedKeyText(@NotNull String decryptedKey){ + public void setDecryptedKeyText(@NotNull String decryptedKey) { decryptedKeyText.setText(decryptedKey); } - public void setDecryptedInformation(@NotNull String decryptedInformationStr){ + public void setDecryptedInformation(@NotNull String decryptedInformationStr) { decryptedInformationBox.setSelectedItem(decryptedInformationStr); } - public void setDecryptedIv(@NotNull String decryptedIvStr){ + public void setDecryptedIv(@NotNull String decryptedIvStr) { decryptedIv.setText(decryptedIvStr); } + + public void setIsHtmlView(@NotNull String isHtmlViewStr){ + isHtmlView.setText(isHtmlViewStr); + } } diff --git a/src/main/java/tech/shiker/config/EncToolConfigurable.java b/src/main/java/tech/shiker/config/EncToolConfigurable.java index 37615c7..a975360 100644 --- a/src/main/java/tech/shiker/config/EncToolConfigurable.java +++ b/src/main/java/tech/shiker/config/EncToolConfigurable.java @@ -38,6 +38,7 @@ public boolean isModified() { modified |= !mySettingsComponent.getDecryptedKey().equals(settings.decryptedKey); modified |= !mySettingsComponent.getDecryptedInformation().equals(settings.decryptedInformation); modified |= !mySettingsComponent.getDecryptedIv().equals(settings.decryptedVi); + modified |= !mySettingsComponent.getIsHtmlView().equals(settings.isHtmlView); return modified; } @@ -48,6 +49,7 @@ public void apply() { settings.decryptedKey = mySettingsComponent.getDecryptedKey(); settings.decryptedInformation = mySettingsComponent.getDecryptedInformation(); settings.decryptedVi = mySettingsComponent.getDecryptedIv(); + settings.isHtmlView = mySettingsComponent.getIsHtmlView(); } @Override @@ -57,6 +59,7 @@ public void reset() { mySettingsComponent.setDecryptedTypeText(settings.decryptedType); mySettingsComponent.setDecryptedInformation(settings.decryptedInformation); mySettingsComponent.setDecryptedIv(settings.decryptedVi); + mySettingsComponent.setIsHtmlView(settings.isHtmlView); } @Override diff --git a/src/main/java/tech/shiker/enccore/DecryptEncAction.java b/src/main/java/tech/shiker/enccore/DecryptEncAction.java index da2c1a0..f81de20 100644 --- a/src/main/java/tech/shiker/enccore/DecryptEncAction.java +++ b/src/main/java/tech/shiker/enccore/DecryptEncAction.java @@ -1,5 +1,8 @@ package tech.shiker.enccore; +import com.intellij.diff.DiffContentFactory; +import com.intellij.diff.DiffManager; +import com.intellij.diff.requests.SimpleDiffRequest; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.CommonDataKeys; @@ -24,7 +27,11 @@ public void actionPerformed(AnActionEvent e) { VirtualFile virtualFile = e.getData(CommonDataKeys.VIRTUAL_FILE); if (virtualFile != null && isYamlOrPropertiesFile(virtualFile)) { try { - processFile(virtualFile); + if("Off".equals(EncSettingState.getInstance().isHtmlView)){ + processFileV2(project, virtualFile); + }else{ + processFile(virtualFile); + } } catch (Exception ex) { Messages.showMessageDialog(ex.getMessage(), SecurityConstant.ENC_DECRYPT_TITLE, Messages.getInformationIcon()); } @@ -39,6 +46,42 @@ private boolean isYamlOrPropertiesFile(VirtualFile virtualFile) { return fileName.endsWith(".yml") || fileName.endsWith(".properties"); } + private void processFileV2(Project project, VirtualFile virtualFile) throws IOException { + String text = new String(virtualFile.contentsToByteArray()); + // 使用正则表达式匹配并解密ENC()格式的字符串 + Pattern pattern = Pattern.compile("ENC\\(([^)]+)\\)"); + Matcher matcher = pattern.matcher(text); + StringBuilder decryptedContent = new StringBuilder(); + int lastEnd = 0; + StringBuilder message = new StringBuilder(); + while (matcher.find()) { + int start = matcher.start(); + int end = matcher.end(); + String encryptedText = matcher.group(1); // 获取ENC()包裹的字符串 + DecryptResult decryptResult = decrypt(encryptedText); // 解密 + + decryptedContent.append(text, lastEnd, start); // 将上次解密位置到本次解密位置之间的内容添加到解密后的文本中 + if (!decryptResult.isDecryptError()) { + decryptedContent.append(decryptResult.decryptStr()); + } else { + message.append(decryptResult.message()).append("\n"); + decryptedContent.append(decryptResult.decryptStr()); + } + lastEnd = end; // 更新上次解密位置 + } + decryptedContent.append(text, lastEnd, text.length()); + if(!message.isEmpty()){ + Messages.showMessageDialog(message.toString(), SecurityConstant.ENC_DECRYPT_TITLE, Messages.getInformationIcon()); + } + DiffContentFactory contentFactory = DiffContentFactory.getInstance(); + SimpleDiffRequest diffRequest = new SimpleDiffRequest("ENC Compare", + contentFactory.create(text), + contentFactory.create(decryptedContent.toString()), + "Source file", "Decrypted file"); + + DiffManager.getInstance().showDiff(project, diffRequest); + } + private void processFile(VirtualFile virtualFile) throws Exception { String text = new String(virtualFile.contentsToByteArray()); // 使用正则表达式匹配并解密ENC()格式的字符串 diff --git a/src/main/java/tech/shiker/security/AesCBCNoPaddingSecurityInstance.java b/src/main/java/tech/shiker/security/AesCBCNoPaddingSecurityInstance.java index f945aa8..753df6a 100644 --- a/src/main/java/tech/shiker/security/AesCBCNoPaddingSecurityInstance.java +++ b/src/main/java/tech/shiker/security/AesCBCNoPaddingSecurityInstance.java @@ -16,7 +16,6 @@ public class AesCBCNoPaddingSecurityInstance implements SecurityInstance{ @Override public EncryptResult encrypt(String src, String key, String index) throws Exception { if (key.length() != 16) { - Messages.showInfoMessage(SecurityConstant.KEY_INVALID_MESSAGE, SecurityConstant.ENC_DECRYPT_TITLE); return new EncryptResult("!!!!ERROR!!!", true, SecurityConstant.KEY_INVALID_MESSAGE); } // 判断Key是否正确 @@ -25,7 +24,6 @@ public EncryptResult encrypt(String src, String key, String index) throws Except } // 判断Key是否为16位 if (index.length() != 16) { - Messages.showInfoMessage(SecurityConstant.KEY_INVALID_MESSAGE, SecurityConstant.ENC_DECRYPT_TITLE); return new EncryptResult("!!!!ERROR!!!", true, SecurityConstant.IV_INVALID_MESSAGE); } Cipher cipher = Cipher.getInstance(SecurityMethod.AES_CBC_NO_PADDING.decryptInformation()); @@ -40,7 +38,6 @@ public EncryptResult encrypt(String src, String key, String index) throws Except public DecryptResult decrypt(String src, String key, String index) throws Exception { // 判断Key是否为16位 if (key.length() != 16) { - Messages.showInfoMessage(SecurityConstant.KEY_INVALID_MESSAGE, SecurityConstant.ENC_DECRYPT_TITLE); return new DecryptResult("!!!!ERROR!!!", true, SecurityConstant.KEY_INVALID_MESSAGE); } // 判断Key是否正确 @@ -49,7 +46,6 @@ public DecryptResult decrypt(String src, String key, String index) throws Except } // 判断Key是否为16位 if (index.length() != 16) { - Messages.showInfoMessage(SecurityConstant.KEY_INVALID_MESSAGE, SecurityConstant.ENC_DECRYPT_TITLE); return new DecryptResult("!!!!ERROR!!!", true, SecurityConstant.IV_INVALID_MESSAGE); } Cipher cipher = Cipher.getInstance(SecurityMethod.AES_CBC_NO_PADDING.decryptInformation()); diff --git a/src/main/java/tech/shiker/security/AesCBCPkcs5PaddingSecurityInstance.java b/src/main/java/tech/shiker/security/AesCBCPkcs5PaddingSecurityInstance.java index 1f24529..fa7c1c8 100644 --- a/src/main/java/tech/shiker/security/AesCBCPkcs5PaddingSecurityInstance.java +++ b/src/main/java/tech/shiker/security/AesCBCPkcs5PaddingSecurityInstance.java @@ -16,7 +16,6 @@ public class AesCBCPkcs5PaddingSecurityInstance implements SecurityInstance { @Override public EncryptResult encrypt(String src, String key, String index) throws Exception { if (key.length() != 16) { - Messages.showInfoMessage(SecurityConstant.KEY_INVALID_MESSAGE, SecurityConstant.ENC_DECRYPT_TITLE); return new EncryptResult("!!!!ERROR!!!", true, SecurityConstant.KEY_INVALID_MESSAGE); } // 判断Key是否正确 @@ -25,7 +24,6 @@ public EncryptResult encrypt(String src, String key, String index) throws Except } // 判断Key是否为16位 if (index.length() != 16) { - Messages.showInfoMessage(SecurityConstant.KEY_INVALID_MESSAGE, SecurityConstant.ENC_DECRYPT_TITLE); return new EncryptResult("!!!!ERROR!!!", true, SecurityConstant.IV_INVALID_MESSAGE); } Cipher cipher = Cipher.getInstance(SecurityMethod.AES_CBC_PKCS5_PADDING.decryptInformation()); @@ -40,7 +38,6 @@ public EncryptResult encrypt(String src, String key, String index) throws Except public DecryptResult decrypt(String src, String key, String index) throws Exception { // 判断Key是否为16位 if (key.length() != 16) { - Messages.showInfoMessage(SecurityConstant.KEY_INVALID_MESSAGE, SecurityConstant.ENC_DECRYPT_TITLE); return new DecryptResult("!!!!ERROR!!!", true, SecurityConstant.KEY_INVALID_MESSAGE); } // 判断Key是否正确 @@ -49,7 +46,6 @@ public DecryptResult decrypt(String src, String key, String index) throws Except } // 判断Key是否为16位 if (index.length() != 16) { - Messages.showInfoMessage(SecurityConstant.KEY_INVALID_MESSAGE, SecurityConstant.ENC_DECRYPT_TITLE); return new DecryptResult("!!!!ERROR!!!", true, SecurityConstant.IV_INVALID_MESSAGE); } Cipher cipher = Cipher.getInstance(SecurityMethod.AES_CBC_PKCS5_PADDING.decryptInformation()); diff --git a/src/main/java/tech/shiker/security/AesECBNoPaddingSecurityInstance.java b/src/main/java/tech/shiker/security/AesECBNoPaddingSecurityInstance.java index 6ac982f..fad0f60 100644 --- a/src/main/java/tech/shiker/security/AesECBNoPaddingSecurityInstance.java +++ b/src/main/java/tech/shiker/security/AesECBNoPaddingSecurityInstance.java @@ -16,7 +16,6 @@ public class AesECBNoPaddingSecurityInstance implements SecurityInstance{ public EncryptResult encrypt(String src, String key) throws Exception { // 判断Key是否为16位 if (key.length() != 16) { - Messages.showInfoMessage(SecurityConstant.KEY_INVALID_MESSAGE, SecurityConstant.ENC_DECRYPT_TITLE); return new EncryptResult("!!!!ERROR!!!", true, SecurityConstant.KEY_INVALID_MESSAGE); } Cipher cipher = Cipher.getInstance(SecurityMethod.AES_ECB_NO_PADDING.decryptInformation()); @@ -35,7 +34,6 @@ public EncryptResult encrypt(String src, String key, String index) throws Except public DecryptResult decrypt(String src, String key) throws Exception { // 判断Key是否为16位 if (key.length() != 16) { - Messages.showInfoMessage(SecurityConstant.KEY_INVALID_MESSAGE, SecurityConstant.ENC_DECRYPT_TITLE); return new DecryptResult("!!!!ERROR!!!", true, SecurityConstant.KEY_INVALID_MESSAGE); } Cipher cipher = Cipher.getInstance(SecurityMethod.AES_ECB_NO_PADDING.decryptInformation()); diff --git a/src/main/java/tech/shiker/security/AesECBPkcs5PaddingSecurityInstance.java b/src/main/java/tech/shiker/security/AesECBPkcs5PaddingSecurityInstance.java index 7d3c22a..44f0df4 100644 --- a/src/main/java/tech/shiker/security/AesECBPkcs5PaddingSecurityInstance.java +++ b/src/main/java/tech/shiker/security/AesECBPkcs5PaddingSecurityInstance.java @@ -16,7 +16,6 @@ public class AesECBPkcs5PaddingSecurityInstance implements SecurityInstance { public EncryptResult encrypt(String src, String encryptedKey) throws Exception { // 判断Key是否为16位 if (encryptedKey.length() != 16) { - Messages.showInfoMessage(SecurityConstant.KEY_INVALID_MESSAGE, SecurityConstant.ENC_DECRYPT_TITLE); return new EncryptResult("!!!!ERROR!!!", true, SecurityConstant.KEY_INVALID_MESSAGE); } Cipher cipher = Cipher.getInstance(SecurityMethod.AES_ECB_PKCS5_PADDING.decryptInformation()); @@ -35,7 +34,6 @@ public EncryptResult encrypt(String src, String key, String index) throws Except public DecryptResult decrypt(String src, String decryptedKey) throws Exception{ // 判断Key是否为16位 if (decryptedKey.length() != 16) { - Messages.showInfoMessage(SecurityConstant.KEY_INVALID_MESSAGE, SecurityConstant.ENC_DECRYPT_TITLE); return new DecryptResult("!!!!ERROR!!!", true, SecurityConstant.KEY_INVALID_MESSAGE); } byte[] raw = decryptedKey.getBytes(StandardCharsets.UTF_8); diff --git a/src/main/java/tech/shiker/security/DesCBCNoPaddingSecurityInstance.java b/src/main/java/tech/shiker/security/DesCBCNoPaddingSecurityInstance.java index 2ce301a..02ea6ae 100644 --- a/src/main/java/tech/shiker/security/DesCBCNoPaddingSecurityInstance.java +++ b/src/main/java/tech/shiker/security/DesCBCNoPaddingSecurityInstance.java @@ -16,7 +16,6 @@ public class DesCBCNoPaddingSecurityInstance implements SecurityInstance{ public EncryptResult encrypt(String src, String key, String index) throws Exception { // 判断Key是否为16位 if (key.length() != 24) { - Messages.showInfoMessage(SecurityConstant.KEY_INVALID_MESSAGE, SecurityConstant.ENC_DECRYPT_TITLE); return new EncryptResult("!!!!ERROR!!!", true, SecurityConstant.KEY_INVALID_MESSAGE); } // 判断Key是否正确 @@ -25,7 +24,6 @@ public EncryptResult encrypt(String src, String key, String index) throws Except } // 判断Key是否为24位 if (index.length() != 8) { - Messages.showInfoMessage(SecurityConstant.KEY_INVALID_MESSAGE, SecurityConstant.ENC_DECRYPT_TITLE); return new EncryptResult("!!!!ERROR!!!", true, SecurityConstant.IV_INVALID_MESSAGE); } Cipher cipher = Cipher.getInstance(SecurityMethod.DES_CBC_NO_PADDING.decryptInformation()); @@ -40,7 +38,6 @@ public EncryptResult encrypt(String src, String key, String index) throws Except public DecryptResult decrypt(String src, String key, String index) throws Exception { // 判断Key是否为16位 if (key.length() != 24) { - Messages.showInfoMessage(SecurityConstant.KEY_INVALID_MESSAGE, SecurityConstant.ENC_DECRYPT_TITLE); return new DecryptResult("!!!!ERROR!!!", true, SecurityConstant.KEY_INVALID_MESSAGE); } if (index == null) { @@ -48,7 +45,6 @@ public DecryptResult decrypt(String src, String key, String index) throws Except } // 判断Key是否为16位 if (index.length() != 8) { - Messages.showInfoMessage(SecurityConstant.KEY_INVALID_MESSAGE, SecurityConstant.ENC_DECRYPT_TITLE); return new DecryptResult("!!!!ERROR!!!", true, SecurityConstant.IV_INVALID_MESSAGE); } Cipher cipher = Cipher.getInstance(SecurityMethod.DES_CBC_NO_PADDING.decryptInformation()); diff --git a/src/main/java/tech/shiker/security/DesCBCPkcs5PaddingSecurityInstance.java b/src/main/java/tech/shiker/security/DesCBCPkcs5PaddingSecurityInstance.java index 774fdad..11539c9 100644 --- a/src/main/java/tech/shiker/security/DesCBCPkcs5PaddingSecurityInstance.java +++ b/src/main/java/tech/shiker/security/DesCBCPkcs5PaddingSecurityInstance.java @@ -17,7 +17,6 @@ public class DesCBCPkcs5PaddingSecurityInstance implements SecurityInstance { public EncryptResult encrypt(String src, String key, String index) throws Exception { // 判断Key是否为16位 if (key.length() != 24) { - Messages.showInfoMessage(SecurityConstant.KEY_INVALID_MESSAGE, SecurityConstant.ENC_DECRYPT_TITLE); return new EncryptResult("!!!!ERROR!!!", true, SecurityConstant.KEY_INVALID_MESSAGE); } // 判断Key是否正确 @@ -26,7 +25,6 @@ public EncryptResult encrypt(String src, String key, String index) throws Except } // 判断Key是否为16位 if (index.length() != 8) { - Messages.showInfoMessage(SecurityConstant.KEY_INVALID_MESSAGE, SecurityConstant.ENC_DECRYPT_TITLE); return new EncryptResult("!!!!ERROR!!!", true, SecurityConstant.IV_INVALID_MESSAGE); } Cipher cipher = Cipher.getInstance(SecurityMethod.DES_CBC_PKCS5_PADDING.decryptInformation()); @@ -41,7 +39,6 @@ public EncryptResult encrypt(String src, String key, String index) throws Except public DecryptResult decrypt(String src, String key, String index) throws Exception { // 判断Key是否为16位 if (key.length() != 24) { - Messages.showInfoMessage(SecurityConstant.KEY_INVALID_MESSAGE, SecurityConstant.ENC_DECRYPT_TITLE); return new DecryptResult("!!!!ERROR!!!", true, SecurityConstant.KEY_INVALID_MESSAGE); } // 判断Key是否正确 @@ -50,7 +47,6 @@ public DecryptResult decrypt(String src, String key, String index) throws Except } // 判断Key是否为16位 if (index.length() != 8) { - Messages.showInfoMessage(SecurityConstant.KEY_INVALID_MESSAGE, SecurityConstant.ENC_DECRYPT_TITLE); return new DecryptResult("!!!!ERROR!!!", true, SecurityConstant.IV_INVALID_MESSAGE); } Cipher cipher = Cipher.getInstance(SecurityMethod.DES_CBC_PKCS5_PADDING.decryptInformation()); diff --git a/src/main/java/tech/shiker/security/DesECBNoPaddingSecurityInstance.java b/src/main/java/tech/shiker/security/DesECBNoPaddingSecurityInstance.java index e67fb41..5bc18ce 100644 --- a/src/main/java/tech/shiker/security/DesECBNoPaddingSecurityInstance.java +++ b/src/main/java/tech/shiker/security/DesECBNoPaddingSecurityInstance.java @@ -16,7 +16,6 @@ public class DesECBNoPaddingSecurityInstance implements SecurityInstance { public EncryptResult encrypt(String src, String key) throws Exception { // 判断Key是否为16位 if (key.length() != 24) { - Messages.showInfoMessage(SecurityConstant.KEY_INVALID_MESSAGE, SecurityConstant.ENC_DECRYPT_TITLE); return new EncryptResult("!!!!ERROR!!!", true, SecurityConstant.KEY_INVALID_MESSAGE); } Cipher cipher = Cipher.getInstance(SecurityMethod.DES_ECB_NO_PADDING.decryptInformation()); @@ -34,7 +33,6 @@ public EncryptResult encrypt(String src, String key, String index) throws Except public DecryptResult decrypt(String src, String key) throws Exception { // 判断Key是否为16位 if (key.length() != 24) { - Messages.showInfoMessage(SecurityConstant.KEY_INVALID_MESSAGE, SecurityConstant.ENC_DECRYPT_TITLE); return new DecryptResult("!!!!ERROR!!!", true, SecurityConstant.KEY_INVALID_MESSAGE); } Cipher cipher = Cipher.getInstance(SecurityMethod.DES_ECB_NO_PADDING.decryptInformation()); diff --git a/src/main/java/tech/shiker/security/DesECBPkcs5PaddingSecurityInstance.java b/src/main/java/tech/shiker/security/DesECBPkcs5PaddingSecurityInstance.java index ba86515..5c4828b 100644 --- a/src/main/java/tech/shiker/security/DesECBPkcs5PaddingSecurityInstance.java +++ b/src/main/java/tech/shiker/security/DesECBPkcs5PaddingSecurityInstance.java @@ -15,7 +15,6 @@ public class DesECBPkcs5PaddingSecurityInstance implements SecurityInstance { public EncryptResult encrypt(String src, String encryptedKey) throws Exception { // 判断Key是否为16位 if (encryptedKey.length() != 24) { - Messages.showInfoMessage(SecurityConstant.KEY_INVALID_MESSAGE, SecurityConstant.ENC_DECRYPT_TITLE); return new EncryptResult("!!!!ERROR!!!", true, SecurityConstant.KEY_INVALID_MESSAGE); } Cipher cipher = Cipher.getInstance(SecurityMethod.DES_ECB_PKCS5_PADDING.decryptInformation()); @@ -34,7 +33,6 @@ public EncryptResult encrypt(String src, String key, String index) throws Except public DecryptResult decrypt(String src, String decryptedKey) throws Exception{ // 判断Key是否为16位 if (decryptedKey.length() != 24) { - Messages.showInfoMessage(SecurityConstant.KEY_INVALID_MESSAGE, SecurityConstant.ENC_DECRYPT_TITLE); return new DecryptResult("!!!!ERROR!!!", true, SecurityConstant.KEY_INVALID_MESSAGE); } byte[] raw = decryptedKey.getBytes(StandardCharsets.UTF_8); diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index 44c9aae..8b45c44 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -24,6 +24,9 @@
  • Feature 2 - encrypt

    demo2

  • +
  • Feature 3 - more style comparison

    +

    style

    +
  • Supported algorithm:

    • AES/ECB/PKCS5Padding