我想使用AES/ECB使用第三方Java代碼來加密數據。提供數據和密鑰。代碼如下: -使用Java加密
import java.security.Key;
import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;
import java.util.Base64;
public class encryptData {
public static void main(String[] args) {
String data="amount=10&expiryDate=20150101 151515&orderRefNum=11001&postBackURL=http://localhost:9081/local/status.php&storeId=28";
String key="89OUITUPRL3I8H3G";
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
SecretKeySpec secretKey = new SecretKeySpec(key.getBytes(), "AES");
cipher.init(Cipher.ENCRYPT_MODE, secretKey);
encryptedValue = new String(Base64.encodeBase64(cipher.doFinal(data.getBytes())));
}
}
我想出來的https://www.compilejava.net/
這是我收到的錯誤: -
/tmp/java_Ramvov/encryptData.java:16: error: cannot find symbol
encryptedValue = new String(Base64.encodeBase64(cipher.doFinal(data.getBytes())));
^
symbol: variable encryptedValue
location: class encryptData
/tmp/java_Ramvov/encryptData.java:16: error: cannot find symbol
encryptedValue = new String(Base64.encodeBase64(cipher.doFinal(data.getBytes())));
^
symbol: method encodeBase64(byte[])
location: class Base64
2個錯誤
我很少有關Java的知識。請幫助
'字符串encryptedValue =新的String(..'你錯過了申報環節 –
的錯誤是很清楚的 - 。encryptedValue沒有定義 – OldProgrammer