package com.bonus.gateway;

import org.jasypt.encryption.StringEncryptor;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;

import javax.annotation.Resource;

/**
 * 网关启动程序
 * 
 * @author bonus
 */
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class })
public class BonusGatewayApplication  implements CommandLineRunner {
    public static void main(String[] args) {
        SpringApplication.run(BonusGatewayApplication.class, args);
        System.err.println("博诺思网关启动成功\n");
    }


    @Resource
    private StringEncryptor encryptor;
    @Override
    public void run(String... args) throws Exception {
        String nacos = encrypt("Jjsp@nacos2023" );
        String nacos2 = encrypt("nacos" );
        String mogodb = encrypt("Bonus@admin123!" );
        System.err.println( "nacos原始明文密码加密后的结果为：" + nacos );
        System.err.println( "nacos2：" + nacos2 );
        System.err.println( "mogodb原始明文密码加密后的结果为：" + mogodb );
    }

    private String encrypt( String originPassord ) {
        return encryptor.encrypt( originPassord );
    }

    private String decrypt( String encryptedPassword ) {
        return encryptor.decrypt( encryptedPassword );
    }
}
