package com.jxy.order.vo;

import com.jxy.common.core.utils.sign.Rsa2Utils;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.io.FileUtils;

import java.io.File;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;

/**
 * @Description TODO
 * @Date 2023/5/30 17:21
 * @Author 杜懿
 */
public class TEst {

    public static void main(String[] args) throws Exception {
        String a ="0x06e810184b1959f7665f2236dc3e6463258effd28743dd5d6f5e3ef60bfa6b20";
        //String en = "wYy5PtlRvQsAMHnO80SY5icK1VM9yVwZAEoqUaI7I0uQyFo7MlNWUbD9YO23robBWTIxBEtDkh/ueA8H9w2/CpsMSFvxaEaY9X6fXckjsU0v157+tcBt5D9E8Tk6/mKx/ogDeAFt38Clp12/ULEMyKVShfRUcv4aeVYG+I2Ou8M=";
        String test1 ="G/yQm4q1J5Gp69Su0PrS64j0NUfeWsCKIkc3+/al2Qz8p8weqIcgPFCStmxkOSvRkeg+V6jnp3hSPPmMdm28VqqOuvxP9toVXbXKuQ8j5U/j8GoPKiwfRpVuGf02GIFm+zVipRmD/IZEk9Ie1CNhMVflYXslLo2lLjmH4GOXRWM=";
        //String path1 ="D:\\JXYS\\Tools\\pk.ppk";
        //String pk1 = FileUtils.readFileToString(new File(path1), StandardCharsets.UTF_8);
        //System.out.println(pk1);
        String en = Rsa2Utils.encryptByPublicKey(Rsa2Utils.publicKey,a);

        String en2 = "G7kHYLrFVLJ+fteY1Y02gtun9BdcZt9kBue+Yhrxxv/pfqJGCvKMTM3dJRPBKC7Igop6NRWSKDeZ9dfXbkCo2Uxv3OHE2nU/e0gLeBqyNF3jKyQvF//mb4p5ea2q5/z1i6kPDT24kgCo6F7aLHwJU0joTDJJEQjotISzKPwYDoE=";
        String en3 = "ro3ODLHyQFEjgvk+df+4ek+ArYFbkFXIBp9vW0jEsP6LDb/3S2cr0VpGkYy2biPMD12kl5QTxIsWYSANGU/GhVLQsYybxtWFD9ku94PXNeCCGe1HRy3FJF5XQnHLjmOCmDQwDgvjXkEKlW6FVcp+M0rr1JquLwEI25DEGDQNfTw=";

        System.out.println("加密得到："+en);
        System.out.println(en.length());
        String path ="D:\\JXYS\\Tools\\pv.pem";
        String pk = FileUtils.readFileToString(new File(path), StandardCharsets.UTF_8);
        String s ="g8z7Tg/TK0FWXdjUekabz91TERElKHvgJY479xq1TVFMSZo1FL5P6g+nLu+Z6nHPIFUmr8nWgJfAn0vRT9eBEusxdZNNsaVKWI2CvqIrTEvKuxs2yWF5HzxWJoXUpvB4JhS2s5ZO7x8bKWoNVHEf8OVvFhj1o56vPTSZzes0dTdfWRgQE/uFwSO0rUeSicsp57c6NltQ2ZkTVM1Acy+c686JTR/U+dRBuVH9PlMpmdUgzLjAWcfH8WFuNrZxEHSLDG9d6fSgMjLb0hDNktPV7ZOAmdp/s9U8u80xwnilHQ1RwIGOGmmlg/3TpU1RpINN4U8dLGO//o8i4pKhe7Dm3g==";
        String s1 = Rsa2Utils.decryptByPrivateKey(Rsa2Utils.privateKey,en);
        String s2 = Rsa2Utils.decryptByPrivateKey(Rsa2Utils.privateKey,en2);
        String s3 = Rsa2Utils.decryptByPrivateKey(Rsa2Utils.privateKey,en3);
        String s4 = Rsa2Utils.decryptByPrivateKey(Rsa2Utils.privateKey,test1);

        System.out.println("解密结果"+s1);
        System.out.println("s2解密结果"+s2);
        System.out.println("s3解密结果"+s3);
        System.out.println(s4);
    }
}
