Found 9150 Articles for Object Oriented Programming

Provider entrySet() method in Java

Samual Sam
Updated on 30-Jul-2019 22:30:25

142 Views

The entries in the Provider have an unmodifiable set view that can be obtained using the method entrySet() in the class java.security.Provider. This method requires no parameters and it returns the unmodifiable set view for the entries in the Provider.A program that demonstrates this is given as follows −Example Live Demoimport java.security.*; import java.util.*; public class Demo {    public static void main(String[] argv) {       try {          SecureRandom sRandom = SecureRandom.getInstance("SHA1PRNG");          Provider p = sRandom.getProvider();          Set set = p.entrySet();          Iterator i = ... Read More

Provider elements() method in Java

karthikeya Boyini
Updated on 30-Jul-2019 22:30:25

135 Views

An enumeration of the values in the hash table can be obtained using the method elements() in the class java.security.Provider. This method requires no parameters and it returns the enumeration of the values in the hash table.A program that demonstrates this is given as follows −Example Live Demoimport java.security.*; import java.util.*; public class Demo {    public static void main(String[] argv) {       try {          SecureRandom sRandom = SecureRandom.getInstance("SHA1PRNG");          Provider p = sRandom.getProvider();          Enumeration enumeration;          enumeration = p.elements();          System.out.println("The ... Read More

AlgorithmParameterGenerator generateParameters() method in Java

Samual Sam
Updated on 30-Jul-2019 22:30:25

136 Views

The parameters can be generated using the method generateParameters() in the class java.security.AlgorithmParameterGenerator. This method requires no parameters and it returns the AlgorithmParameter object.A program that demonstrates this is given as follows −Example Live Demoimport java.security.*; import java.util.*; public class Demo {    public static void main(String[] argv) {       try {          AlgorithmParameterGenerator apGenerator = AlgorithmParameterGenerator.getInstance("DiffieHellman");          apGenerator.init(1024);          AlgorithmParameters aParameters = apGenerator.generateParameters();          System.out.println(aParameters);       } catch (NoSuchAlgorithmException e) {          System.out.println("Error!!! NoSuchAlgorithmException");       } catch (ProviderException e) ... Read More

AlgorithmParameterGenerator getAlgorithm() method in Java

karthikeya Boyini
Updated on 30-Jul-2019 22:30:25

72 Views

The algorithm name for the parameter generator can be obtained using the method getAlgorithm() in the class java.security.AlgorithmParameterGenerator. This method requires no parameters and it returns the algorithm name in string form.A program that demonstrates this is given as follows −Example Live Demoimport java.security.*; import java.util.*; public class Demo {    public static void main(String[] argv) {       try {          AlgorithmParameterGenerator apGenerator = AlgorithmParameterGenerator.getInstance("DiffieHellman");          apGenerator.init(1024);          String algorithm = apGenerator.getAlgorithm();          System.out.println("The Algorithm is: " + algorithm);       } catch (NoSuchAlgorithmException e) { ... Read More

AlgorithmParameterGenerator getProvider() method in Java

Samual Sam
Updated on 30-Jul-2019 22:30:25

94 Views

The provider of the generator object can be obtained using the method getProvider() in the class java.security.AlgorithmParameterGenerator. This method requires no parameters and it returns the provider of the generator object.A program that demonstrates this is given as follows −Example Live Demoimport java.security.*; import java.util.*; public class Demo {    public static void main(String[] argv) {       try {          AlgorithmParameterGenerator apGenerator = AlgorithmParameterGenerator.getInstance("DiffieHellman");          apGenerator.init(1024);          Provider provider = apGenerator.getProvider();          System.out.println("The Provider is: " + provider);       } catch (NoSuchAlgorithmException e) { ... Read More

KeyFactory getAlgorithm() method in Java

karthikeya Boyini
Updated on 30-Jul-2019 22:30:25

105 Views

The algorithm name for the KeyFactory can be obtained using the method getAlgorithm() in the class java.security.KeyFactory. This method requires no parameters and it returns the algorithm name for the KeyFactory.A program that demonstrates this is given as follows −Example Live Demoimport java.security.*; import java.util.*; import java.security.spec.*; public class Demo {    public static void main(String[] argv) throws Exception {       try {          KeyFactory kf = KeyFactory.getInstance("RSA");          String algorithm = kf.getAlgorithm();          System.out.println("The Algortihm is: " + algorithm);       } catch (NoSuchAlgorithmException e) { ... Read More

KeyPairGenerator getAlgorithm() method in Java

Samual Sam
Updated on 30-Jul-2019 22:30:25

90 Views

The algorithm name for the key pair generator can be obtained using the method getAlgorithm() in the class java.security.KeyPairGenerator. This method requires no parameters and it returns the algorithm name for the key pair generator.A program that demonstrates this is given as follows −Example Live Demoimport java.security.*; import java.util.*; public class Demo {    public static void main(String[] argv) {       try {          KeyPairGenerator kpGenerator = KeyPairGenerator.getInstance("DSA");          String algorithm = kpGenerator.getAlgorithm();          System.out.println("The Algorithm is: " + algorithm);       } catch (NoSuchAlgorithmException e) {     ... Read More

KeyPairGenerator getProvider() method in Java

karthikeya Boyini
Updated on 30-Jul-2019 22:30:25

96 Views

The provider of the key pair object can be obtained using the getProvider() method in the class java.security.KeyPairGenerator. This method requires no parameters and it returns the provider of the key pair object.A program that demonstrates this is given as follows −Example Live Demoimport java.security.*; import java.util.*; public class Demo {    public static void main(String[] argv) {       try {          KeyPairGenerator kpGenerator = KeyPairGenerator.getInstance("DSA");          Provider p = kpGenerator.getProvider();          System.out.println("The Provider is: " + p.getName());       } catch (NoSuchAlgorithmException e) { ... Read More

KeyPairGenerator getInstance() method in Java

Samual Sam
Updated on 30-Jul-2019 22:30:25

198 Views

A KeyPairGenerator object with the key pairs for a particular algorithm can be obtained using the getInstance() method in the class java.security.KeyPairGenerator. This method requires a single parameter i.e. the algorithm name and it returns the KeyPairGenerator object created.A program that demonstrates this is given as follows −Example Live Demoimport java.security.*; import java.util.*; public class Demo {    public static void main(String[] argv) {       try {          KeyPairGenerator kpGenerator = KeyPairGenerator.getInstance("RSA");          String algorithm = kpGenerator.getAlgorithm();          System.out.println("The Algorithm is: " + algorithm);       } catch (NoSuchAlgorithmException ... Read More

KeyPairGenerator generateKeyPair() method in Java

karthikeya Boyini
Updated on 30-Jul-2019 22:30:25

179 Views

A key pair can be generated using the generateKeyPair() method in the class java.security.KeyPairGenerator. This method requires no parameters and it returns the key pair that is generated. Every time the generateKeyPair() method is called, it generates a new key pair.A program that demonstrates this is given as follows −Example Live Demoimport java.security.*; import java.util.*; public class Demo {    public static void main(String[] argv) throws Exception {       try {          KeyPairGenerator kpGenerator = KeyPairGenerator.getInstance("RSA");          KeyPair keyPair = kpGenerator.generateKeyPair();          System.out.println(keyPair);       } catch (NoSuchAlgorithmException e) ... Read More

Advertisements