Sunday 13 July 2014

NoSuchAlgorithmException

This exception is thrown when a particular cryptographic algorithm is requested but is not available in the environment.

Example
import javax.crypto.KeyGenerator;
import java.security.NoSuchAlgorithmException;

public class SecretKeyEx {
    public static void main(String args[])throws NoSuchAlgorithmException{
        KeyGenerator keyGen = KeyGenerator.getInstance("ptr");
    }
}

When you tries to compile the above program below error thrown.

Exception in thread "main" java.security.NoSuchAlgorithmException: ptr KeyGenerator not available
 at javax.crypto.KeyGenerator.<init>(KeyGenerator.java:159)
 at javax.crypto.KeyGenerator.getInstance(KeyGenerator.java:208)
 at SecretKeyEx.main(SecretKeyEx.java:18)
Java Result: 1


Since there is no cryptographic Algorithm like ptr in the Environment.




                                                             Home

No comments:

Post a Comment