Samual Sam

Samual Sam

1,507 Articles Published

Articles by Samual Sam

Page 8 of 151

MD5 hash encoding using Python?

Samual Sam
Samual Sam
Updated on 11-Mar-2026 5K+ Views

One of the major concern of all IT companies in the security of there data. Multiple hashing techniques are there to project and check our data.What is HashHash is a function which takes variable length sequence of bytes as input and converts it to a fixed length sequence. However, to get your original data(input bytes) back is not easy. For example, x is your input and f is the f is the hashing function, then calculating f(x) is quick and easy but trying to obtain x again is a very time-consuming job.The return value from a hash function is called ...

Read More

Keyed-Hashing for Message Authentication in python

Samual Sam
Samual Sam
Updated on 11-Mar-2026 1K+ Views

Message authentication using cryptographic hash functions in python can be achieved through the HMAC mechanism. We can use HMAC with multiple iterable hash functions such as MD5, SHA-1 in combination with a secret shared key.The basic idea is to secure our data, by generating a cryptographic hash of the actual data combined with a shared secret key. The final result is sent without the secret key but the resulting hash can be used to check the transmitted or stored message.Syntaxhmac.new(key, msg = None, digestmod = None)Returns a generate new hmac object.Where −Key – The shared secret key here.Msg – the ...

Read More

Create a HashMap in Java

Samual Sam
Samual Sam
Updated on 11-Mar-2026 350 Views

To create a HashMap, use the HashMap map and new −HashMap hm = new HashMap();Now, set elements −hm.put("Finance", new Double(999.87)); hm.put("Operations", new Double(298.64)); hm.put("Marketing", new Double(39.56));Display the elements now using the following code −Exampleimport java.util.*; public class Demo { public static void main(String args[]) { // Create a hash map HashMap hm = new HashMap(); // Put elements to the map hm.put("Finance", new Double(999.87)); hm.put("Operations", new Double(298.64)); ...

Read More

Barrier Objects in Python

Samual Sam
Samual Sam
Updated on 11-Mar-2026 584 Views

Barrier provides one of the python synchronization technique with which single or multiple threads wait until a point in a set of activities and make progress together.To define a barrier object, “threading. Barrier” is used.threading.Barrier(parties, action = None, timeout = None)Where, parties = Number of threadsaction = called by one of the threads when they are released.timeout = Default timeout value. In case no timeout value is specified for the wait(), this timeout value is used.Below mentioned methods are used by Barrier class.Sr.NoMethod & Description1partiesA number of threads required to reach the common barrier point.2n_waitingNumber of threads waiting in the ...

Read More

Fix for java.math.BigInteger cannot be cast to java.lang.Integer?

Samual Sam
Samual Sam
Updated on 11-Mar-2026 6K+ Views

You can typecast with the help of method intValue(). The syntax is as follows −Integer yourVariableName=((BigInteger) yourBigIntegerValue).intValue();Here is the Java code to convert java.math.BigInteger cast to java.lang.Integer. The code is as follows −Exampleimport java.math.BigInteger; public class BigIntegerToInteger {    public static void main(String []args) {       BigInteger bigValue [] = new BigInteger[5];       bigValue[0] = new BigInteger("6464764");       bigValue[1] = new BigInteger("212112221122");       bigValue[2] = new BigInteger("76475");       bigValue[3] = new BigInteger("94874747");       bigValue[4] = new BigInteger("2635474");       for(int i = 0; i< bigValue.length; i++) { ...

Read More

Display HashMap elements in Java

Samual Sam
Samual Sam
Updated on 11-Mar-2026 658 Views

Create a HashMap −HashMap hm = new HashMap();Add elements to the HashMap that we will be displaying afterward −hm.put("Maths", new Integer(98)); hm.put("Science", new Integer(90)); hm.put("English", new Integer(97)); hm.put("Physics", new Integer(91));Now, to display the HashMap elements, use Iterator. The following is an example to display HashMap elements −Exampleimport java.util.*; public class Demo { public static void main(String args[]) { // Create a hash map HashMap hm = new HashMap(); // Put elements to the map ...

Read More

ShortBuffer order() Method in Java

Samual Sam
Samual Sam
Updated on 11-Mar-2026 135 Views

The byte order of the buffer can be obtained using the method order() in the class java.nio.ShortBuffer. This method requires no parameters and it returns the byte order of the buffer.A program that demonstrates this is given as follows −Exampleimport java.nio.*; import java.util.*; public class Demo {    public static void main(String[] args) {       int n = 5;       try {          ShortBuffer buffer = ShortBuffer.allocate(n);          buffer.put((short)12);          buffer.put((short)91);          buffer.put((short)25);          buffer.put((short)18);          buffer.put((short)30);   ...

Read More

Use ListIterator to traverse an ArrayList in the reverse direction in Java

Samual Sam
Samual Sam
Updated on 11-Mar-2026 2K+ Views

A ListIterator can be used to traverse the elements in the forward direction as well as the reverse direction in the List Collection. So the ListIterator is only valid for classes such as LinkedList, ArrayList etc.The method hasPrevious( ) in ListIterator returns true if there are more elements in the List while traversing in the reverse direction and false otherwise. The method previous( ) returns the previous element in the List and reduces the cursor position backward.A program that demonstrates this is given as follows −Exampleimport java.util.ArrayList; import java.util.ListIterator; public class Demo {    public static void main(String[] args) { ...

Read More

Provider values() method in Java

Samual Sam
Samual Sam
Updated on 11-Mar-2026 193 Views

The property values in the Provider can be viewed with an unmodifiable Collection view that is obtained using the method values() in the class java.security.Provider. This method requires no parameters and it returns an unmodifiable Collection view of the property values.A program that demonstrates this is given as follows −Exampleimport java.security.*; import java.util.*; public class Demo {    public static void main(String[] argv) throws Exception {       try {          Signature sign = Signature.getInstance("DSA");          Provider p = sign.getProvider();          Collection val = p.values();          Iterator ...

Read More

Check whether two HashSet are equal in Java

Samual Sam
Samual Sam
Updated on 11-Mar-2026 468 Views

At first, create the first HashSet and add elements to it −// create hash set 1 HashSet hs1 = new HashSet(); hs1.add("G"); hs1.add("H"); hs1.add("I"); hs1.add("J"); hs1.add("K");Create the second HashSet and add elements to it −// create hash set 2 HashSet hs2 = new HashSet(); hs2.add("G"); hs2.add("H"); hs2.add("I"); hs2.add("J"); hs2.add("K");To check whether both the HashSet are equal or not, use the equals() method −hs1.equals(hs2)The following is an example to check whether two HashSet are equal −Exampleimport java.util.*; public class Demo { public static void main(String args[]) { // create hash set 1 ...

Read More
Showing 71–80 of 1,507 articles
« Prev 1 6 7 8 9 10 151 Next »
Advertisements