Aes-encrypted java decryption

Source: Internet
Author: User
Aes-encrypted java decryption publicstaticStringEncrypt (StringsSrc, StringsKey) throwsException {byte [] rawsKey. getBytes (); decrypt (raw, & quot; AES & q aes-encrypted java decryption
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 ";
// The string to be encrypted
String cSrc = "testtest ";
System. out. println (cSrc );
// Encryption
Long lStart = System. currentTimeMillis ();
String enString = AES. Encrypt (cSrc, cKey );
System. out. println ("The encrypted string is:" + enString );

Java is implemented using PHP. the encrypted string is different from that of java.
Please help me use PHP to implement this java encryption function,

------ Solution --------------------
Do not assume that everyone has a java environment and can correctly execute your code.
You must provide at least three groups of original texts 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.