diff --git a/src/main/java/com/mattrixwv/CipherStreamJava/monoSubstitution/Affine.java b/src/main/java/com/mattrixwv/CipherStreamJava/monoSubstitution/Affine.java index 49770f8..b8ef99f 100644 --- a/src/main/java/com/mattrixwv/CipherStreamJava/monoSubstitution/Affine.java +++ b/src/main/java/com/mattrixwv/CipherStreamJava/monoSubstitution/Affine.java @@ -8,6 +8,8 @@ package com.mattrixwv.CipherStreamJava.monoSubstitution; import com.mattrixwv.CipherStreamJava.exceptions.InvalidInputException; import com.mattrixwv.CipherStreamJava.exceptions.InvalidKeywordException; +import mattrixwv.NumberAlgorithms; + public class Affine{ private boolean preserveCapitals; @@ -26,7 +28,7 @@ public class Affine{ } //Make sure the key is relatively prime to 26 (The number of letters) - if(gcd(key1, 26) != 1){ + if(NumberAlgorithms.gcd(key1, 26) != 1){ throw new InvalidKeywordException("Key 1 must be relatively prime to 26"); } @@ -186,17 +188,4 @@ public class Affine{ public int getKey2(){ return key2; } - //TODO: Change to my library's version - //This function returns the GCD of the two numbers sent to it - public static int gcd(int num1, int num2){ - while((num1 != 0) && (num2 != 0)){ - if(num1 > num2){ - num1 %= num2; - } - else{ - num2 %= num1; - } - } - return num1 | num2; - } }