package com.TinyPro.utils;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.PBEKeySpec;
import java.security.spec.KeySpec;
import java.util.Base64;
public class Sha256Utils {
public static String encry(String value, String salt) throws Exception {
int iterations = 1000;
int keyLength = 18;
KeySpec spec = new PBEKeySpec(value.toCharArray(), salt.getBytes(), iterations, keyLength * 8);
SecretKeyFactory factory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA256");
byte[] hashedPassword = factory.generateSecret(spec).getEncoded();
return Base64.getEncoder().encodeToString(hashedPassword);
}
}