package cn.com.countrygarden.bi.main.util;

import org.junit.Test;
import sun.misc.BASE64Decoder;

import java.nio.charset.Charset;

public class Des3EncodeCBCTest {
    @Test
    public void test() throws Exception {
//        key ：IJZVYCX798GABX7GLREUKBD1
//        iv ：HDATKKIL
        String key = "IJZVYCX798GABX7GLREUKBD1";
        String iv = "HDATKKIL";
        String data = "{\n" +
                "                \"startTime\": \"2019/12/25 00:00\",\n" +
                "                \"endTime\": \"2019/12/25 24:00\"\n" +
                "}";
        byte[] bytes = Des3EncodeCBC.des3EncodeCBC(key.getBytes(), iv.getBytes(), data.getBytes());
        String s = new String(bytes);
        System.out.println(s);
    }

    @Test
    public void test2() throws Exception {
//        key ：IJZVYCX798GABX7GLREUKBD1
//        iv ：HDATKKIL
        String key = "IJZVYCX798GABX7GLREUKBD1";
        String iv = "HDATKKIL";
        String str = "ooTh58EGaF2LbLN3bqzzrM9e86q/P55PQwSe1W/0Ny55Tbvs70PRWY1eZ9Dhwd4ESl+ykW1i3rLhuJ3xkpo0kiBB0uoDYJg1";


        byte[] keyBytes = "IJZVYCX798GABX7GLREUKBD1".getBytes();//"";//new BASE6Decoder().decodeBuffer("IJZVYCX798GABX7GLREUKBD1");
        byte[] keyiv = {72, 68, 65, 84, 75, 75, 73, 76};
        Charset charset = Charset.forName("UTF-8");
        byte[] bytes = Des3EncodeCBC.des3DecodeCBC(keyBytes, keyiv, str.getBytes(charset));
        String s = new String(bytes);
        System.out.println(s);
    }

    @Test
    public void test3() throws Exception {
        byte[] key = "IJZVYCX798GABX7GLREUKBD1".getBytes();
        byte[] keyiv = "HDATKKIL".getBytes();
        byte[] bytes = new BASE64Decoder().decodeBuffer("ooTh58EGaF2LbLN3bqzzrM9e86q/P55PQwSe1W/0Ny55Tbvs70PRWY1eZ9Dhwd4ESl+ykW1i3rLhuJ3xkpo0kiBB0uoDYJg1");
        byte[] str6 = Des3EncodeCBC.des3DecodeCBC(key, keyiv, bytes);
        String s = new String(str6, "UTF-8");
        System.out.println(s);
    }

}


//
//<p class="control">
//<a class="button is-white is-large" target="_blank" title="Creative Commons" href="https://creativecommons.org/">
//<i class="fab fa-creative-commons"></i> </a>
//</p>
//
//<p class="control">
//<a class="button is-white is-large" target="_blank" title="Attribution 4.0 International" href="https://creativecommons.org/licenses/by/4.0/">
//<i class="fab fa-creative-commons-by"></i>
//</a>
//</p>
//
//<p  class="control">
//        &copy; ${.now?string('yyyy')}  FEMENT.FUN 乏善可陈  ${user.nickname!}&nbsp;
//<a href="http://www.beian.miit.gov.cn" target="_blank">湘ICP备19023726号&nbsp;</a>
//<img src="http://www.beian.gov.cn/img/ghs.png"/>
//        粤公网安备44060602001469号
//</p>