package com.cusc.nirvana.user.rnr.fp.constants;

import com.cusc.nirvana.user.util.crypt.DataCryptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;

import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author stayAnd
 * @date 2022/5/16
 */
@Component
public class CryptKeyHelper {

	private static DataCryptService cryptService;


	@Autowired
	public void setDataCryptService(DataCryptService cryptService){
		CryptKeyHelper.cryptService = cryptService;
	}


	public static List<String> encrypt(List<String> list){
		if (CollectionUtils.isEmpty(list)) {
			return Collections.emptyList();
		}
		List<String> collect = list.stream().map(CryptKeyHelper::encrypt).collect(Collectors.toList());
		return collect;
	}

	public static String encrypt(String s){
		return cryptService.encryptData(s);
	}


}
