chengkun
2025-06-05 4080b5997b38ca84b3b203c7101dcadb97b76925
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/**
 * Alipay.com Inc.
 * Copyright (c) 2004-2020 All Rights Reserved.
 */
package com.alipay.easysdk.util.aes;
 
import com.alipay.easysdk.TestAccount.Mini;
import com.alipay.easysdk.factory.Factory;
import com.alipay.easysdk.kernel.Config;
import org.junit.Before;
import org.junit.Test;
 
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
 
public class ClientTest {
 
    @Before
    public void setUp() {
        Config config = Mini.getConfig();
        config.encryptKey = "aa4BtZ4tspm2wnXLb1ThQA==";
        Factory.setOptions(config);
    }
 
    @Test
    public void testDecrypt() throws Exception {
        String plainText = Factory.Util.AES().decrypt("ILpoMowjIQjfYMR847rnFQ==");
        assertThat(plainText, is("test1234567"));
    }
 
    @Test
    public void testEncrypt() throws Exception {
        String cipherText = Factory.Util.AES().encrypt("test1234567");
        assertThat(cipherText, is("ILpoMowjIQjfYMR847rnFQ=="));
    }
}