suchen

Heim  >  Fragen und Antworten  >  Hauptteil

So implementieren Sie die PbeWithMd5AndDes-Verschlüsselung und -Entschlüsselung von Java in PHP

public static String encrypt(String key, String plainText){   String encryptTxt = "";   try {      byte[] salt = new byte[8];      MessageDigest md = MessageDigest.getInstance("MD5");      md.update(key.getBytes());      byte[]digest = md.digest();      for (int i = 0; i < 8; i++) {         salt[i] = verdauen[i];      }      PBEKeySpec pbeKeySpec = new PBEKeySpec(key.toCharArray());      SecretKeyFactory keyFactory = SecretKeyFactory            .getInstance("PBEWithMD5AndDES");      SecretKey skey = keyFactory.generateSecret(pbeKeySpec);      PBEParameterSpec paramSpec = new PBEParameterSpec(salt, ITERATIONS);      Cipher cipher = Cipher.getInstance("PBEWithMD5AndDES");      cipher.init(Cipher.ENCRYPT_MODE, skey, paramSpec);      byte[] cipherText = cipher.doFinal(plainText.getBytes());      String saltString = new String(Base64.encode(salt));      String ciphertextString = new String(Base64.encode(cipherText));      return saltString + ciphertextString;   } Catch (Ausnahme e) {      e.printStackTrace();   }   return "";}将这段java 加密使用PHP进行解密

七1582 Tage vor2457

Antworte allen(0)Ich werde antworten

Keine Antwort
  • StornierenAntwort