import javax.crypto.Cipher;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.PBEKeySpec;
import javax.crypto.spec.PBEParameterSpec;
import java.security.spec.AlgorithmParameterSpec;
import java.security.spec.KeySpec;
import java.util.Base64;
public class PBEEncryptionExample {
public static void main(String[] args) throws Exception {
String textToEncrypt = "http://111.180.195.228:5147/api.php?act=user_logon&app=10000";
String password = "your_password_here";
SecretKeyFactory factory = SecretKeyFactory.getInstance("PBEWithMD5AndDES");
KeySpec keySpec = new PBEKeySpec(password.toCharArray());
SecretKey secretKey = factory.generateSecret(keySpec);
Cipher cipher = Cipher.getInstance("PBEWithMD5AndDES");
AlgorithmParameterSpec paramSpec = new PBEParameterSpec(new byte[]{1, 2, 3, 4, 5, 6, 7, 8}, 1000);
cipher.init(Cipher.ENCRYPT_MODE, secretKey, paramSpec);
byte[] encrypted = cipher.doFinal(textToEncrypt.getBytes());
String encryptedBase64 = Base64.getEncoder().encodeToString(encrypted);
System.out.println("Encrypted text: " + encryptedBase64);
}
}