Navicate导出数据库密码
Navicate导出数据库密码
- Navicate导出数据库密码
- 1.导出连接文件
- 2.代码
Navicate导出数据库密码
你好! 这是你第一次使用 Markdown编辑器 所展示的欢迎页。如果你想学习如何使用Markdown编辑器, 可以仔细阅读这篇文章,了解一下Markdown的基本语法知识。
1.导出连接文件
勾选导出密码
2.代码
package com.hoover.daily.utils;import cn.hutool.core.io.file.FileReader;
import cn.hutool.crypto.symmetric.AES;
import org.dom4j.*;import java.util.Iterator;public class NavicatDecrypt {public static void main(String[] args) throws DocumentException {//整体参考:http://t.zoukankan.com/lori-p-15686959.html// 指定导出文件FileReader fileReader = new FileReader("d:\\user\\00\\desktop\\connections2.ncx");String result = fileReader.readString();System.out.println("==================获取文件内容==================");System.out.println(result);Document document = DocumentHelper.parseText(result);Element root = document.getRootElement();Iterator<Element> connectionList = root.elementIterator("Connection");connectionList.forEachRemaining(v -> {Element connection = v;System.out.println("==================获取导出参数==================");String connectionName = connection.attributeValue("ConnectionName");String connType = connection.attributeValue("ConnType");String host = connection.attributeValue("Host");String port = connection.attributeValue("Port");String userName = connection.attributeValue("UserName");String encryPassword = connection.attributeValue("Password");String database = connection.attributeValue("Database");System.out.println("1.------->连接名称:" + connectionName);System.out.println("2.------->数据库类型:" + connType);System.out.println("3.------->主机(IP):" + host);System.out.println("4.------->端口:" + port);System.out.println("5.------->用户名:" + userName);
// System.out.println("5.------->encryPassword:" + encryPassword);//解密//参考https://the-x.cn/cryptography/Aes.aspxAES aes = new AES("CBC", "PKCS7Padding", "libcckeylibcckey".getBytes(), "libcciv libcciv ".getBytes());String val = aes.decryptStr(encryPassword);System.out.println("6.------->密码:" + val);System.out.println("7.------->数据库名称:" + database);System.out.println("==============================================");System.out.println();System.out.println();System.out.println();System.out.println("================以下为全部连接信息================");Iterator<Attribute> attributeIterator = connection.attributeIterator();while (attributeIterator.hasNext()) {Attribute attribute = attributeIterator.next();
// System.out.println(attribute.getName() + ":" + attribute.getValue());}});}
}