package com.huimv.management;

import com.huimv.common.utils.Constant;
import com.huimv.management.rsa.JdkSignatureUtil;
import org.apache.tomcat.util.codec.binary.Base64;

import javax.crypto.Cipher;
import java.security.*;
import java.security.interfaces.RSAPrivateKey;
import java.security.interfaces.RSAPublicKey;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.X509EncodedKeySpec;
import java.util.Date;
import java.util.Random;


/**
 * @author yinhao
 * @Date 2021/4/29 16:58
 * @Description
 */
public class Abc {

    private static final String PUBLIC = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAn4fJrNHB3pPehgdejK9q0mZA8S3Au4ODOL3qvdV0sedj8jTv0wLulCiSbrXIOlvn4SOSVUyGtuX8GhlIM0I5sEqw1h+ydV4SHu8KyrMMwZmAy0app3JYNnFCpsi3hVgOI6XWT/coinZcFXe0DPMdzj/75Ybn6peO0yu/ldMqawVxDa6idlVfaf5U9LncqPeDBIXUirkEZUz5G9S6dq0WwnCdRyQ+5MQgFUTEop+EOhp/iR3RVUGJrqNOCv7ym0v/RwgNigOvG212jvWkGqQ7SpDXXHJK0rr34KNYEjO2YC7JDaOg+QMaaObToVaPzzsDkF+GsocQoCDL9re+UtoDRQIDAQAB";

    private static final String PRIVATE = "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCfh8ms0cHek96GB16Mr2rSZkDxLcC7g4M4veq91XSx52PyNO/TAu6UKJJutcg6W+fhI5JVTIa25fwaGUgzQjmwSrDWH7J1XhIe7wrKswzBmYDLRqmnclg2cUKmyLeFWA4jpdZP9yiKdlwVd7QM8x3OP/vlhufql47TK7+V0yprBXENrqJ2VV9p/lT0udyo94MEhdSKuQRlTPkb1Lp2rRbCcJ1HJD7kxCAVRMSin4Q6Gn+JHdFVQYmuo04K/vKbS/9HCA2KA68bbXaO9aQapDtKkNdcckrSuvfgo1gSM7ZgLskNo6D5Axpo5tOhVo/POwOQX4ayhxCgIMv2t75S2gNFAgMBAAECggEAQ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GXAfR7OSL8Zx8POHWM0GKH/vkaWi5axO3P2feO4nqFvB5l9g0RpxvaoyeRt6OmH1v+BDo5SS7WCt+QjTaEexbrYZgCUNWx0xLO53F4+RKpybMfe8w2v9rZyZ6+avCoqiGsfXGjKAClBDdppw=";

//    public static void main(String[] args) throws InvalidKeySpecException, NoSuchAlgorithmException, InvalidKeyException, SignatureException {
////        System.out.println(DateUtil.date());
////        DateTime dateTime = DateUtil.offsetDay(DateUtil.date(), 1);
////        System.out.println(dateTime);
////        DateTime dateTime1 = DateUtil.beginOfDay(dateTime);
////        System.out.println(dateTime1);
////        long between = DateUtil.between(DateUtil.date(), dateTime1, DateUnit.SECOND);
////        System.out.println(between);
//        StringBuffer sb = new StringBuffer();
//        sb.append("token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJhdXRoMCIsImV4cCI6MTYyMDI5ODk3MX0.nL-qBjjshGWWLkT1Si5MpjZ_6kA_VcF443Iq2jbEG7g&");
//
//        Random random = new Random();
//        sb.append("random=").append(random.nextInt(100)).append("&");
//        sb.append("timestamp=").append(System.currentTimeMillis());
//
//        String paramStr = sb.toString();
//
//        String sign = JdkSignatureUtil.executeSignature(Constant.RSA_SIGN_PRIVATE_KEY, paramStr);
//
//        System.out.println(paramStr);
//
//
//        System.out.println(sign);
//    }

    public static void main(String[] args) throws NoSuchAlgorithmException {
//        System.currentTimeMillis()
//        /*创建非对称加密的公钥和私钥示例 将生成的公钥和私钥用Base64编码后打印出来*/
//        KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA");
//        keyPairGenerator.initialize(2048); //一般加密位数为1024 对安全要求较高的情况下可以使用2048
//        KeyPair keyPair = keyPairGenerator.generateKeyPair();
//        RSAPublicKey publicKey = (RSAPublicKey) keyPair.getPublic();
//        RSAPrivateKey privateKey = (RSAPrivateKey) keyPair.getPrivate();
//        /*将公钥base64编码打印出来*/        System.out.println(Base64.encodeBase64String(publicKey.getEncoded()));
//        /*将私钥base64编码打印出来*/      System.out.println(Base64.encodeBase64String(privateKey.getEncoded()));
//
//        KeyFactory keyFactory = new KeyFactory();
//        /*公钥字符串*/
//        String pubKey= PUBLIC;
//        /*X.509 标准中定义的公钥编码标准，使用这个类进行转换*/
//        X509EncodedKeySpec x509KeySpec = new X509EncodedKeySpec(Base64.decodeBase64(PUBLIC));
////获得公钥对象
//        PublicKey publicKey = keyFactory.generatePublic(x509KeySpec);
//        String msg="需要加密的内容";
//        /*使用Cipher加密*/
//        /*定义加密方式*/
//        Cipher cipher = Cipher.getInstance("RSA");
//        /*使用公钥和加密模式初始化*/
//        cipher.init(Cipher.ENCRYPT_MODE, publicKey);
//        /*获取加密内容以UTF-8为标准转化的字节进行加密后再使用base64编码成字符串*/
//        /*加密后的字符串*/
//        String enmsg=Base64.encodeBase64String(cipher.doFinal(plainText.getBytes("UTF-8")));
        Date date = new Date(0L);
        System.out.println(date);

        int i =(int) Double.parseDouble("39.5");
        System.out.println(i);

        Object o = null;
        String s = String.valueOf(o);
        if (s != null) System.out.println(s);
    }
}
