Function 在给定的函数decrypt中,我希望将文件geek.txt的内容作为参数传递给encryptedText
我想用geek.txt文件的内容替换encryptedText。该文件包含3行中的3个字。如何将其中一个字作为参数传递给此函数Function 在给定的函数decrypt中,我希望将文件geek.txt的内容作为参数传递给encryptedText,function,arguments,file-handling,Function,Arguments,File Handling,我想用geek.txt文件的内容替换encryptedText。该文件包含3行中的3个字。如何将其中一个字作为参数传递给此函数 { public static String decrypt(String encryptedText, SecretKey secretKey)//how should i replace the encryptedText argument with some content of a file geek.txt throws Exception
{
public static String decrypt(String encryptedText, SecretKey secretKey)//how should i replace the encryptedText argument with some content of a file geek.txt
throws Exception {
Base64.Decoder decoder = Base64.getDecoder();
byte[] encryptedTextByte = decoder.decode(encryptedText);
cipher.init(Cipher.DECRYPT_MODE, secretKey);
byte[] decryptedByte = cipher.doFinal(encryptedTextByte);
String decryptedText = new String(decryptedByte);
return decryptedText;
}
}