- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 34483 Articles for Programming
109 Views
The number of seed bytes can be obtained using the method generateSeed() in class java.security.SecureRandom. This method requires a single parameter i.e. the number of seed bytes and it returns the seed bytes that are generated.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"); byte[] arrB = sRandom.generateSeed(5); System.out.println("The seed bytes generated are: " + Arrays.toString(arrB)); } catch (NoSuchAlgorithmException e) ... Read More
233 Views
A SecureRandom object can be obtained using the getInstance() method in class java.security.SecureRandom. This SecureRandom object is useful in implementing the Random Number Generator (RNG) algorithm that is specified.The getInstance() method requires a single parameter i.e. the Random Number Generator (RNG) algorithm and it returns the SecureRandom 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 { SecureRandom sRandom = SecureRandom.getInstance("SHA1PRNG"); String s = "Apple"; byte[] arrB = ... Read More
1K+ Views
A signature object that can implement the required signature algorithm can be obtained using the method getInstance() in the class java.security.Signature. This method requires a single parameter i.e. the standard algorithm name and it returns the signature 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 { Signature signature = Signature.getInstance("SHA256withRSA"); String str = signature.toString(); System.out.println(str); } catch (NoSuchAlgorithmException e) { ... Read More
275 Views
The string representation for the signature object can be obtained using the method getString() in the class java.security.Signature. This includes information such as the object state, algorithm name etc. The method getString() requires no parameters and it returns the provider for the signature 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 { Signature signature = Signature.getInstance("SHA256withRSA"); ... Read More
129 Views
The provider for the signature object can be obtained using the method getProvider() in the class java.security.Signature. This method requires no parameters and it returns the provider for the signature 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 { Signature signature = Signature.getInstance("SHA256withRSA"); Provider provider = signature.getProvider(); System.out.println("The Provider is: " + provider); } catch (NoSuchAlgorithmException e) { ... Read More
152 Views
The name of the algorithm for the signature object can be obtained using the method getAlgorithm() in the class java.security.Signature. This method requires no parameters and it returns the name of the algorithm for the signature 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 { Signature signature = Signature.getInstance("SHA256withRSA"); String algorithm = signature.getAlgorithm(); System.out.println("The Algorithm is: " + algorithm); } catch (NoSuchAlgorithmException e) { ... Read More
96 Views
A new CharBuffer can be allocated using the method allocate() in the class java.nio.CharBuffer. This method requires a single parameter i.e. the capacity of the buffer. It returns the new CharBuffer that is allocated. If the capacity provided is negative, then the IllegalArgumentException is thrown.A program that demonstrates this is given as follows −Example Live Demoimport java.nio.*; import java.util.*; public class Demo { public static void main(String[] args) { int n = 5; try { CharBuffer buffer = CharBuffer.allocate(n); buffer.put('A'); buffer.put('P'); ... Read More
74 Views
A duplicate buffer of a buffer can be created using the method duplicate() in the class java.nio.CharBuffer. This duplicate buffer is identical to the original buffer. The method duplicate() returns the duplicate buffer that was created.A program that demonstrates this is given as follows −Example Live Demoimport java.nio.*; import java.util.*; public class Demo { public static void main(String[] args) { int n = 5; try { CharBuffer buffer1 = CharBuffer.allocate(5); buffer1.put('A'); buffer1.put('P'); buffer1.put('P'); buffer1.put('L'); ... Read More
67 Views
The buffer can be compacted using the compact() method in the class java.nio.CharBuffer. This method does not require a parameter and it returns the new compacted CharBuffer with the same content as the original buffer. If the buffer is read-only, then the ReadOnlyBufferException is thrown.A program that demonstrates this is given as follows −Example Live Demoimport java.nio.*; import java.util.*; public class Demo { public static void main(String[] args) { int n = 5; try { CharBuffer buffer = CharBuffer.allocate(n); buffer.put('A'); buffer.put('B'); ... Read More
77 Views
A new CharBuffer with the content as a shared subsequence of the original CharBuffer can be created using the method slice() in the class java.nio.CharBuffer. This method returns the new CharBuffer that is read-only if the original buffer is read-only and direct if the original buffer is direct.A program that demonstrates this is given as follows −Example Live Demoimport java.nio.*; import java.util.*; public class Demo { public static void main(String[] args) { int n = 5; try { CharBuffer buffer1 = CharBuffer.allocate(n); buffer1.put('A'); ... Read More