I am fairly new to Java and attempting to use the Java Crypto extension, so far I have this, except Eclipse is throwing errors on the lines with the * and I'm not sure why. I added in the *... they are not in the code normally.
private static byte[] getKey(byte[] paramArrayOfByte)
throws NoSuchAlgorithmException
{
KeyGenerator localKeyGenerator = KeyGenerator.getInstance("AES");
try
{
SecureRandom localSecureRandom1;
SecureRandom localSecureRandom2 = SecureRandom.getInstance("SHA1PRNG", "Crypto");
* localSecureRandom1 = localSecureRandom2;
* localSecureRandom1.setSeed(paramArrayOfByte);
* localKeyGenerator.init(128, localSecureRandom1);
return localKeyGenerator.generateKey().getEncoded();
}
catch (NoSuchProviderException localNoSuchProviderException)
{
while (true)
* SecureRandom localSecureRandom1 = SecureRandom.getInstance("SHA1PRNG");
}
}
all fixed, copy and paste error on my part, the infinite loop was for testing.
Assuming you introduced the asterisks ( *
) to highlight the problematic lines:
localSecureRandom1
is not declared on the first line marked, and that should also be the message the compiler gives you. localSecureRandom1
is then declared in the catch
-clause, which doesn't make sense catch
-clause
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.