Found 33676 Articles for Programming

C++ Program to Implement the Vigenere Cypher

Nishtha Thakur
Updated on 30-Jul-2019 22:30:26

8K+ Views

Vigenere Cipher is a kind of polyalphabetic substitution method of encrypting alphabetic text.Vigenere Cipher Table is used in which alphabets from A to Z are written in 26 rows, for encryption and decryption in this method.EncryptionKey: WELCOMEMessage: ThisistutorialspointHere we have to obtain a key by repeating the given key till its length becomes equal to original message length.For encryption take first letter of message and key i.e. T and W. Take the alphabet in Vigenere Cipher Table where T row and W column coincides i.e. P.Repeat the same process for all remaining alphabets in message text.Finally, the encrypted message text ... Read More

C++ Program to Implement the Hill Cypher

Smita Kapse
Updated on 30-Jul-2019 22:30:26

8K+ Views

Based on linear algebra Hill cipher is a polygraphic substitution cipher in cryptography.To encrypt message: The key string and message string are represented as matrix form. They are multiplied then, against modulo 26. The key matrix should have inverse to decrypt the message.To decrypt message: The encrypted message is multiplied by inverse key matrix used for encryption against modulo 26 to get decrypt message.For exampleKey matrix1 0 1 2 4 0 3 5 6Message string ‘ABC’ in matrix form −0 1 2For encryptionAfter multiplying above two matrices we get, 2 4 17Which will be the encrypted message ‘CER’For decryptionInverse of ... Read More

C++ Program to Implement the RSA Algorithm

Anvi Jain
Updated on 17-May-2021 06:43:38

18K+ Views

RSA is an asymmetric cryptography algorithm which works on two keys-public key and private key.AlgorithmsBegin    1. Choose two prime numbers p and q.    2. Compute n = p*q.    3. Calculate phi = (p-1) * (q-1).    4. Choose an integer e such that 1 < e < phi(n) and gcd(e, phi(n)) = 1; i.e., e and phi(n) are coprime.    5. Calculate d as d ≡ e−1 (mod phi(n)); here, d is the modular multiplicative inverse of e modulo phi(n).    6. For encryption, c = me mod n, where m = original message.    7. For ... Read More

C++ Program to Decode a Message Encoded Using Playfair Cipher

Nishtha Thakur
Updated on 30-Jul-2019 22:30:26

484 Views

In this scheme, pairs of letters are encrypted, instead of single letters as in the case of simple substitution cipher.In playfair cipher, initially a key table is created. The key table is a 5×5 grid of alphabets that acts as the key for encrypting the plaintext. Each of the 25 alphabets must be unique and one letter of the alphabet (usually J) is omitted from the table as we need only 25 alphabets instead of 26. If the plaintext contains J, then it is replaced by I.The sender and the receiver deicide on a particular key, say ‘tutorials’. In a ... Read More

C++ Program to Encode a Message Using Playfair Cipher

Smita Kapse
Updated on 30-Jul-2019 22:30:26

6K+ Views

In this scheme, pairs of letters are encrypted, instead of single letters as in the case of simple substitution cipher.In playfair cipher, initially a key table is created. The key table is a 5×5 grid of alphabets that acts as the key for encrypting the plaintext. Each of the 25 alphabets must be unique and one letter of the alphabet (usually J) is omitted from the table as we need only 25 alphabets instead of 26. If the plaintext contains J, then it is replaced by I.The sender and the receiver deicide on a particular key, say ‘tutorials’. In a ... Read More

C++ Program to Implement Caesar Cypher

Anvi Jain
Updated on 30-Jul-2019 22:30:26

28K+ Views

It is a mono-alphabetic cipher wherein each letter of the plaintext is substituted by another letter to form the ciphertext. It is a simplest form of substitution cipher scheme.This cryptosystem is generally referred to as the Shift Cipher. The concept is to replace each alphabet by another alphabet which is ‘shifted’ by some fixed number between 0 and 25.For this type of scheme, both sender and receiver agree on a ‘secret shift number’ for shifting the alphabet. This number which is between 0 and 25 becomes the key of encryption.The name ‘Caesar Cipher’ is occasionally used to describe the Shift ... Read More

C++ Program to Perform Finite State Automaton based Search

Farhan Muhamed
Updated on 18-Jun-2025 19:18:27

874 Views

An automaton with a finite number of states is called a Finite Automaton. We can use a Finite State Automaton (FSA) to perform optimized pattern search operation on a string. This article will discuss how to implement a Finite State Automaton based search in C++. Problem Statement: Given two strings text[] and pattern[], we want to find all occurrences of the pattern in the text using a Finite State Automaton. // Input Strings text[] = "tutorialsPoint provides premium tutorials on various topics" pattern[] = "tutorials" // Output Pattern found at index 0 and 32 Finite State ... Read More

What happens when JDialog is set with Modality type APPLICATION_MODAL

Krantik Chavan
Updated on 30-Jul-2019 22:30:26

314 Views

The JDialog Modality type APPLICATION_MODAL blocks all top-level windows and it has restrictions. The following is an example to set JDialog with Modality type APPLICATION_MODAL:Exampleimport java.awt.Cursor; import java.awt.Dialog.ModalityType; import java.awt.Dimension; import java.awt.event.ActionEvent; import javax.swing.AbstractAction; import javax.swing.JButton; import javax.swing.JDialog; import javax.swing.JFrame; public class SwingDemo {    public static void main(String[] args) {       JFrame frame = new JFrame();       frame.setSize(new Dimension(600, 400));       JDialog dialog = new JDialog(frame, "New", ModalityType.APPLICATION_MODAL);       dialog.setSize(300, 300);       frame.add(new JButton(new AbstractAction("Click to generate") {          @Override          public void ... Read More

How to pre-select JComboBox item by index in Java?

Krantik Chavan
Updated on 30-Jul-2019 22:30:26

1K+ Views

The following is an example to pre-select JComboBox item by index in Java. Here, we have selected the 3rd item by default i.e. whenever the Swing program will run, the third item would be visible instead of the 1st.Exampleimport java.awt.BorderLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JComboBox; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JTextArea; public class SwingDemo {    public static void main(String[] args) {       JPanel panel = new JPanel(new BorderLayout());       String[] strArr = new String[] { "Laptop", "Mobile", "Desktop", "Tablet" };       JComboBox comboBox = new JComboBox(strArr);       panel.add(comboBox, ... Read More

How to display the items in a JComboBox in Java

Krantik Chavan
Updated on 30-Jul-2019 22:30:26

788 Views

The following is an example to display the first element in a JComboBox in Java:Exampleimport java.awt.BorderLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JComboBox; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JTextArea; public class SwingDemo {    public static void main(String[] args) {       JPanel panel = new JPanel(new BorderLayout());       String[] strArr = new String[] { "Laptop", "Mobile", "Desktop", "Tablet" };       JComboBox comboBox = new JComboBox(strArr);       panel.add(comboBox, BorderLayout.NORTH);       JTextArea text = new JTextArea(5, 5);       panel.add(text, BorderLayout.CENTER);       JButton btn = new JButton("Click");   ... Read More

Advertisements