AES encryption Java decryption related issues

Source: Internet
Author: User
AES Encrypted Java decryption problem
public static string Encrypt (String sSrc, String SKey) throws Exception {
Byte[] raw = skey.getbytes ();
Secretkeyspec Skeyspec = new Secretkeyspec (Raw, "AES");
Cipher Cipher = cipher.getinstance ("aes/cbc/pkcs5padding");
Ivparameterspec IV = new Ivparameterspec ("0102030405060708". GetBytes ());
Cipher.init (Cipher.encrypt_mode, Skeyspec, iv);
Byte[] encrypted = Cipher.dofinal (Ssrc.getbytes ());

return new Base64encoder (). Encode (encrypted);
}

String ckey = "1234567890";
Strings that need to be encrypted
String CSRC = "Testtest";
System.out.println (CSRC);
Encryption
Long Lstart = System.currenttimemillis ();
String enstring = AES. Encrypt (CSRC, Ckey);
System.out.println ("Encrypted string is:" + enstring);

The Java function is implemented in PHP, and the encrypted string is not the same as the Java end.
Please help me to use PHP to implement this cryptographic function of Java,

------Solution--------------------
Don't assume that people have a Java environment and that they can execute your code correctly
You need at least 3 sets of original text and ciphertext.
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.