Refactor Code Style (#4151)

This commit is contained in:
Saurabh Rahate
2023-04-15 13:55:54 +05:30
committed by GitHub
parent 1ce907625b
commit 1dc388653a
100 changed files with 293 additions and 319 deletions

View File

@ -11,7 +11,7 @@ package com.thealgorithms.ciphers;
public class Blowfish {
//Initializing substitution boxes
String S[][] = {
String[][] S = {
{
"d1310ba6",
"98dfb5ac",
@ -1047,7 +1047,7 @@ public class Blowfish {
};
//Initializing subkeys with digits of pi
String P[] = {
String[] P = {
"243f6a88",
"85a308d3",
"13198a2e",
@ -1146,7 +1146,7 @@ public class Blowfish {
The outputs are added modulo 232 and XORed to produce the final 32-bit output
*/
private String f(String plainText) {
String a[] = new String[4];
String[] a = new String[4];
String ans = "";
for (int i = 0; i < 8; i += 2) {
//column number for S-box is a 8-bit value

View File

@ -22,7 +22,7 @@ public class HillCipher {
System.out.println("Enter key matrix size");
int matrixSize = userInput.nextInt();
System.out.println("Enter Key/encryptionKey matrix ");
int keyMatrix[][] = new int[matrixSize][matrixSize];
int[][] keyMatrix = new int[matrixSize][matrixSize];
for (int i = 0; i < matrixSize; i++) {
for (int j = 0; j < matrixSize; j++) {
keyMatrix[i][j] = userInput.nextInt();
@ -33,7 +33,7 @@ public class HillCipher {
int[][] messageVector = new int[matrixSize][1];
String CipherText = "";
int cipherMatrix[][] = new int[matrixSize][1];
int[][] cipherMatrix = new int[matrixSize][1];
int j = 0;
while (j < message.length()) {
for (int i = 0; i < matrixSize; i++) {
@ -69,7 +69,7 @@ public class HillCipher {
System.out.println("Enter key matrix size");
int n = userInput.nextInt();
System.out.println("Enter inverseKey/decryptionKey matrix ");
int keyMatrix[][] = new int[n][n];
int[][] keyMatrix = new int[n][n];
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
keyMatrix[i][j] = userInput.nextInt();
@ -81,7 +81,7 @@ public class HillCipher {
//solving for the required plaintext message
int[][] messageVector = new int[n][1];
String PlainText = "";
int plainMatrix[][] = new int[n][1];
int[][] plainMatrix = new int[n][1];
int j = 0;
while (j < message.length()) {
for (int i = 0; i < n; i++) {
@ -111,13 +111,13 @@ public class HillCipher {
}
// Determinant calculator
public static int determinant(int a[][], int n) {
public static int determinant(int[][] a, int n) {
int det = 0, sign = 1, p = 0, q = 0;
if (n == 1) {
det = a[0][0];
} else {
int b[][] = new int[n - 1][n - 1];
int[][] b = new int[n - 1][n - 1];
for (int x = 0; x < n; x++) {
p = 0;
q = 0;

View File

@ -4,7 +4,7 @@ import java.util.Scanner;
class ProductCipher {
public static void main(String args[]) {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter the input to be encrypted: ");
String substitutionInput = sc.nextLine();