MCPcopy Create free account
hub / github.com/TheAlgorithms/Java / addBin

Method addBin

src/main/java/com/thealgorithms/ciphers/Blowfish.java:1140–1148  ·  view source on GitHub ↗

This method returns addition of two hexadecimal numbers passed as parameters and moded with 2^32 @param String a and b are hexadecimal numbers @return String object which is a is addition that is then moded with 2^32 of hex numbers passed as parameters

(String a, String b)

Source from the content-addressed store, hash-verified

1138 * passed as parameters
1139 */
1140 private String addBin(String a, String b) {
1141 String ans = "";
1142 long n1 = Long.parseUnsignedLong(a, 16);
1143 long n2 = Long.parseUnsignedLong(b, 16);
1144 n1 = (n1 + n2) % modVal;
1145 ans = Long.toHexString(n1);
1146 ans = "00000000" + ans;
1147 return ans.substring(ans.length() - 8);
1148 }
1149
1150 /*F-function splits the 32-bit input into four 8-bit quarters
1151 and uses the quarters as input to the S-boxes.

Callers 1

fMethod · 0.95

Calls 1

lengthMethod · 0.80

Tested by

no test coverage detected