在安全性要求较高的系统中,建议应使用安全的加密算法(如AES、RSA)对敏感数据进行加密。
BufferedReader bufread2 = null;
InputStreamReader inread2 = null;
try {
inread2 = new InputStreamReader(System.in);
bufread2 = new BufferedReader(inread2);
String str = bufread2.readLine();
/* FIX: Secure cryptographic algorithm (AES) */
Cipher aes = Cipher.getInstance("AES");
KeyGenerator kg = KeyGenerator.getInstance("AES");
kg.init(128);
SecretKey key = kg.generateKey();
aes.init(Cipher.ENCRYPT_MODE, key);
byte[] enc_str = aes.doFinal(str.getBytes());
IO.writeLine(IO.toHex(enc_str));
} catch(IOException e) {
log_gsnk.warning("Error reading from console");
} finally{
...
}