package com.huimv.employment.dao.tools;

import com.alibaba.druid.filter.config.ConfigTools;

/**
 * 本地生成 Druid RSA 密钥对及加密密码，运行后用于 application-dev.yml 配置。
 */
public class DruidConfigToolsMain {

    public static void main(String[] args) throws Exception {
        String plainPassword = args.length > 0 ? args[0] : "hm123456";
        String[] keyPair = ConfigTools.genKeyPair(512);
        String privateKey = keyPair[0];
        String publicKey = keyPair[1];
        String encrypted = ConfigTools.encrypt(privateKey, plainPassword);

        System.out.println("plain=" + plainPassword);
        System.out.println("publicKey=" + publicKey);
        System.out.println("encrypted=" + encrypted);
        System.out.println("verify=" + ConfigTools.decrypt(publicKey, encrypted));
    }
}
