package com.qmth.boot.test.core.security;

import com.qmth.boot.core.security.service.EncryptService;
import com.qmth.boot.core.security.service.impl.DefaultEncryptKeyProvider;
import com.qmth.boot.core.security.service.impl.DefaultEncryptService;
import org.apache.commons.lang3.RandomStringUtils;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;

public class EncryptServiceTest {

    private static EncryptService encryptService;

    @BeforeClass
    public static void prepare() {
        encryptService = new DefaultEncryptService(new DefaultEncryptKeyProvider());
    }

    @Test
    public void test() {
        String text = RandomStringUtils.random(64, true, true);
        Assert.assertEquals(text, encryptService.decrypt(encryptService.encrypt(text)));
        System.out.println(encryptService.encrypt("root"));
    }
}
