diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..9650a4e Binary files /dev/null and b/.DS_Store differ diff --git a/.cproject b/.cproject new file mode 100644 index 0000000..5e0c132 --- /dev/null +++ b/.cproject @@ -0,0 +1,927 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4144fa1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,38 @@ +# Prerequisites +*.d + +# Compiled Object files +*.slo +*.lo +*.o +*.obj + +# Precompiled Headers +*.gch +*.pch + +# Compiled Dynamic libraries +*.so +*.dylib +*.dll + +# Fortran module files +*.mod +*.smod + +# Compiled Static libraries +*.lai +*.la +*.a +*.lib + +# Executables +*.exe +*.out +*.app + +# XCode project +*.xcodeproj +xcuserdata/ +EnigmaMachine.xcodeproj +.DS_Store diff --git a/.project b/.project new file mode 100644 index 0000000..ec53fe2 --- /dev/null +++ b/.project @@ -0,0 +1,71 @@ + + + EnigmaSim + + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + ?name? + + + + org.eclipse.cdt.make.core.append_environment + true + + + org.eclipse.cdt.make.core.buildArguments + + + + org.eclipse.cdt.make.core.buildCommand + make + + + org.eclipse.cdt.make.core.buildLocation + ${workspace_loc:/EnigmaSim/Debug} + + + org.eclipse.cdt.make.core.contents + org.eclipse.cdt.make.core.activeConfigSettings + + + org.eclipse.cdt.make.core.enableAutoBuild + false + + + org.eclipse.cdt.make.core.enableCleanBuild + true + + + org.eclipse.cdt.make.core.enableFullBuild + true + + + org.eclipse.cdt.make.core.stopOnError + true + + + org.eclipse.cdt.make.core.useDefaultBuildCmd + true + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.core.ccnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + + diff --git a/.settings/org.eclipse.cdt.managedbuilder.core.prefs b/.settings/org.eclipse.cdt.managedbuilder.core.prefs new file mode 100644 index 0000000..d4cc1e6 --- /dev/null +++ b/.settings/org.eclipse.cdt.managedbuilder.core.prefs @@ -0,0 +1,26 @@ +#Sat Jul 11 20:12:08 IST 2020 +eclipse.preferences.version=1 +environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug.1001932859/CPATH/delimiter=; +environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug.1001932859/CPATH/operation=remove +environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug.1001932859/CPLUS_INCLUDE_PATH/delimiter=; +environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug.1001932859/CPLUS_INCLUDE_PATH/operation=remove +environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug.1001932859/C_INCLUDE_PATH/delimiter=; +environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug.1001932859/C_INCLUDE_PATH/operation=remove +environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug.1001932859/append=true +environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug.1001932859/appendContributed=true +environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.release.1101643224/CPATH/delimiter=; +environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.release.1101643224/CPATH/operation=remove +environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.release.1101643224/CPLUS_INCLUDE_PATH/delimiter=; +environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.release.1101643224/CPLUS_INCLUDE_PATH/operation=remove +environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.release.1101643224/C_INCLUDE_PATH/delimiter=; +environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.release.1101643224/C_INCLUDE_PATH/operation=remove +environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.release.1101643224/append=true +environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.release.1101643224/appendContributed=true +environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.mingw.exe.debug.1001932859/LIBRARY_PATH/delimiter=; +environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.mingw.exe.debug.1001932859/LIBRARY_PATH/operation=remove +environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.mingw.exe.debug.1001932859/append=true +environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.mingw.exe.debug.1001932859/appendContributed=true +environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.mingw.exe.release.1101643224/LIBRARY_PATH/delimiter=; +environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.mingw.exe.release.1101643224/LIBRARY_PATH/operation=remove +environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.mingw.exe.release.1101643224/append=true +environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.mingw.exe.release.1101643224/appendContributed=true diff --git a/EnigmaMachine/.DS_Store b/EnigmaMachine/.DS_Store new file mode 100644 index 0000000..9fa36f4 Binary files /dev/null and b/EnigmaMachine/.DS_Store differ diff --git a/EnigmaMachine/EnigmaMachine.xcodeproj/project.pbxproj b/EnigmaMachine/EnigmaMachine.xcodeproj/project.pbxproj new file mode 100644 index 0000000..e5ee540 --- /dev/null +++ b/EnigmaMachine/EnigmaMachine.xcodeproj/project.pbxproj @@ -0,0 +1,318 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 50; + objects = { + +/* Begin PBXBuildFile section */ + 642ADE3024B9C4F900C0A06A /* Reflector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 642ADE2E24B9C4F900C0A06A /* Reflector.cpp */; }; + 64FDE08A24B8E42F003D1B0D /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 64FDE08924B8E42F003D1B0D /* main.cpp */; }; + 64FDE09224B8E48E003D1B0D /* EnigmaMachine.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 64FDE09024B8E48E003D1B0D /* EnigmaMachine.cpp */; }; + 64FDE09924B8F57E003D1B0D /* RotorSet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 64FDE09724B8F57E003D1B0D /* RotorSet.cpp */; }; + 64FDE0A424B925CF003D1B0D /* Rotor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 64FDE0A224B925CF003D1B0D /* Rotor.cpp */; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 64FDE08424B8E42F003D1B0D /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = /usr/share/man/man1/; + dstSubfolderSpec = 0; + files = ( + ); + runOnlyForDeploymentPostprocessing = 1; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 642ADE2E24B9C4F900C0A06A /* Reflector.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Reflector.cpp; sourceTree = ""; }; + 642ADE2F24B9C4F900C0A06A /* Reflector.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = Reflector.hpp; sourceTree = ""; }; + 64FDE08624B8E42F003D1B0D /* EnigmaMachine */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = EnigmaMachine; sourceTree = BUILT_PRODUCTS_DIR; }; + 64FDE08924B8E42F003D1B0D /* main.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = ""; }; + 64FDE09024B8E48E003D1B0D /* EnigmaMachine.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = EnigmaMachine.cpp; sourceTree = ""; }; + 64FDE09124B8E48E003D1B0D /* EnigmaMachine.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = EnigmaMachine.hpp; sourceTree = ""; }; + 64FDE09724B8F57E003D1B0D /* RotorSet.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = RotorSet.cpp; sourceTree = ""; }; + 64FDE09824B8F57E003D1B0D /* RotorSet.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = RotorSet.hpp; sourceTree = ""; }; + 64FDE0A224B925CF003D1B0D /* Rotor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Rotor.cpp; sourceTree = ""; }; + 64FDE0A324B925CF003D1B0D /* Rotor.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Rotor.hpp; sourceTree = ""; }; + 64FDE0A624B926DC003D1B0D /* config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = config.h; sourceTree = ""; }; + 64FDE0A724B926DC003D1B0D /* utils.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = utils.hpp; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 64FDE08324B8E42F003D1B0D /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 64FDE07D24B8E42F003D1B0D = { + isa = PBXGroup; + children = ( + 64FDE08824B8E42F003D1B0D /* EnigmaMachine */, + 64FDE08724B8E42F003D1B0D /* Products */, + ); + sourceTree = ""; + }; + 64FDE08724B8E42F003D1B0D /* Products */ = { + isa = PBXGroup; + children = ( + 64FDE08624B8E42F003D1B0D /* EnigmaMachine */, + ); + name = Products; + sourceTree = ""; + }; + 64FDE08824B8E42F003D1B0D /* EnigmaMachine */ = { + isa = PBXGroup; + children = ( + 64FDE0A524B926DC003D1B0D /* Utils */, + 64FDE0A224B925CF003D1B0D /* Rotor.cpp */, + 64FDE0A324B925CF003D1B0D /* Rotor.hpp */, + 64FDE08924B8E42F003D1B0D /* main.cpp */, + 64FDE09024B8E48E003D1B0D /* EnigmaMachine.cpp */, + 64FDE09124B8E48E003D1B0D /* EnigmaMachine.hpp */, + 64FDE09724B8F57E003D1B0D /* RotorSet.cpp */, + 64FDE09824B8F57E003D1B0D /* RotorSet.hpp */, + 642ADE2E24B9C4F900C0A06A /* Reflector.cpp */, + 642ADE2F24B9C4F900C0A06A /* Reflector.hpp */, + ); + path = EnigmaMachine; + sourceTree = ""; + }; + 64FDE0A524B926DC003D1B0D /* Utils */ = { + isa = PBXGroup; + children = ( + 64FDE0A624B926DC003D1B0D /* config.h */, + 64FDE0A724B926DC003D1B0D /* utils.hpp */, + ); + path = Utils; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 64FDE08524B8E42F003D1B0D /* EnigmaMachine */ = { + isa = PBXNativeTarget; + buildConfigurationList = 64FDE08D24B8E42F003D1B0D /* Build configuration list for PBXNativeTarget "EnigmaMachine" */; + buildPhases = ( + 64FDE08224B8E42F003D1B0D /* Sources */, + 64FDE08324B8E42F003D1B0D /* Frameworks */, + 64FDE08424B8E42F003D1B0D /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = EnigmaMachine; + productName = EnigmaMachine; + productReference = 64FDE08624B8E42F003D1B0D /* EnigmaMachine */; + productType = "com.apple.product-type.tool"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 64FDE07E24B8E42F003D1B0D /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 1130; + ORGANIZATIONNAME = "Ayush Agrawal"; + TargetAttributes = { + 64FDE08524B8E42F003D1B0D = { + CreatedOnToolsVersion = 11.3; + }; + }; + }; + buildConfigurationList = 64FDE08124B8E42F003D1B0D /* Build configuration list for PBXProject "EnigmaMachine" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 64FDE07D24B8E42F003D1B0D; + productRefGroup = 64FDE08724B8E42F003D1B0D /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 64FDE08524B8E42F003D1B0D /* EnigmaMachine */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXSourcesBuildPhase section */ + 64FDE08224B8E42F003D1B0D /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 64FDE0A424B925CF003D1B0D /* Rotor.cpp in Sources */, + 64FDE09224B8E48E003D1B0D /* EnigmaMachine.cpp in Sources */, + 642ADE3024B9C4F900C0A06A /* Reflector.cpp in Sources */, + 64FDE08A24B8E42F003D1B0D /* main.cpp in Sources */, + 64FDE09924B8F57E003D1B0D /* RotorSet.cpp in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 64FDE08B24B8E42F003D1B0D /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.15; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + }; + name = Debug; + }; + 64FDE08C24B8E42F003D1B0D /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.15; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = macosx; + }; + name = Release; + }; + 64FDE08E24B8E42F003D1B0D /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = 562SMMQ9U5; + ENABLE_HARDENED_RUNTIME = YES; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 64FDE08F24B8E42F003D1B0D /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = 562SMMQ9U5; + ENABLE_HARDENED_RUNTIME = YES; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 64FDE08124B8E42F003D1B0D /* Build configuration list for PBXProject "EnigmaMachine" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 64FDE08B24B8E42F003D1B0D /* Debug */, + 64FDE08C24B8E42F003D1B0D /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 64FDE08D24B8E42F003D1B0D /* Build configuration list for PBXNativeTarget "EnigmaMachine" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 64FDE08E24B8E42F003D1B0D /* Debug */, + 64FDE08F24B8E42F003D1B0D /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 64FDE07E24B8E42F003D1B0D /* Project object */; +} diff --git a/EnigmaMachine/EnigmaMachine.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/EnigmaMachine/EnigmaMachine.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..94ff194 --- /dev/null +++ b/EnigmaMachine/EnigmaMachine.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/EnigmaMachine/EnigmaMachine.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/EnigmaMachine/EnigmaMachine.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/EnigmaMachine/EnigmaMachine.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/EnigmaMachine/EnigmaMachine.xcodeproj/project.xcworkspace/xcuserdata/ayushagrawal.xcuserdatad/UserInterfaceState.xcuserstate b/EnigmaMachine/EnigmaMachine.xcodeproj/project.xcworkspace/xcuserdata/ayushagrawal.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 0000000..69b92cc Binary files /dev/null and b/EnigmaMachine/EnigmaMachine.xcodeproj/project.xcworkspace/xcuserdata/ayushagrawal.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/EnigmaMachine/EnigmaMachine.xcodeproj/xcuserdata/ayushagrawal.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/EnigmaMachine/EnigmaMachine.xcodeproj/xcuserdata/ayushagrawal.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist new file mode 100644 index 0000000..695f077 --- /dev/null +++ b/EnigmaMachine/EnigmaMachine.xcodeproj/xcuserdata/ayushagrawal.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -0,0 +1,6 @@ + + + diff --git a/EnigmaMachine/EnigmaMachine.xcodeproj/xcuserdata/ayushagrawal.xcuserdatad/xcschemes/xcschememanagement.plist b/EnigmaMachine/EnigmaMachine.xcodeproj/xcuserdata/ayushagrawal.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 0000000..f43f716 --- /dev/null +++ b/EnigmaMachine/EnigmaMachine.xcodeproj/xcuserdata/ayushagrawal.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,14 @@ + + + + + SchemeUserState + + EnigmaMachine.xcscheme_^#shared#^_ + + orderHint + 0 + + + + diff --git a/EnigmaMachine/EnigmaMachine/EnigmaMachine.cpp b/EnigmaMachine/EnigmaMachine/EnigmaMachine.cpp new file mode 100644 index 0000000..a96218f --- /dev/null +++ b/EnigmaMachine/EnigmaMachine/EnigmaMachine.cpp @@ -0,0 +1,31 @@ +// +// Enigma.cpp +// EnigmaMachine +// +// Created by Ayush Agrawal on 10/07/20. +// Copyright © 2020 Ayush Agrawal. All rights reserved. +// + +#include "EnigmaMachine.hpp" +#include "Utils/utils.hpp" + +EnigmaMachine::EnigmaMachine(int rot_nos[NO_OF_ROTORS], int reflectorType): _rotorSet(rot_nos, reflectorType) { + for (int i = 0; i < 26; i++){ + _intCharMap.push_back('A' + i); + } +} + + +std::string EnigmaMachine::encode(std::string inputStr){ + std::string inpCopy = custom_utils::removeSpace(inputStr); + + inpCopy = custom_utils::toUppercase(inpCopy); + + std::string outputStr; + for (int i = 0; i < inpCopy.size(); i++){ + char charOut = _rotorSet.parseValue( inpCopy[i] ); + outputStr.push_back(charOut); + } + + return outputStr; +} diff --git a/EnigmaMachine/EnigmaMachine/EnigmaMachine.hpp b/EnigmaMachine/EnigmaMachine/EnigmaMachine.hpp new file mode 100644 index 0000000..f0d031a --- /dev/null +++ b/EnigmaMachine/EnigmaMachine/EnigmaMachine.hpp @@ -0,0 +1,21 @@ +// +// Enigma.hpp +// EnigmaMachine +// +// Created by Ayush Agrawal on 10/07/20. +// Copyright © 2020 Ayush Agrawal. All rights reserved. +// + +#pragma once +#include "RotorSet.hpp" +#include +#include + +class EnigmaMachine { + RotorSet _rotorSet; + std::string _intCharMap; + +public: + EnigmaMachine(int rot_nos[NO_OF_ROTORS], int reflectorType); + std::string encode(std::string input); +}; diff --git a/EnigmaMachine/EnigmaMachine/Reflector.cpp b/EnigmaMachine/EnigmaMachine/Reflector.cpp new file mode 100644 index 0000000..e3afef0 --- /dev/null +++ b/EnigmaMachine/EnigmaMachine/Reflector.cpp @@ -0,0 +1,48 @@ +// +// Reflector.cpp +// EnigmaMachine +// +// Created by Ayush Agrawal on 11/07/20. +// Copyright © 2020 Ayush Agrawal. All rights reserved. +// + +#include "Reflector.hpp" + +Reflector::Reflector(int type){ + _rotorNo = type; + setWiring(_rotorNo); +} + +char Reflector::runThrough(char input, bool forward = true) { + int intInp; + char output; + + forward = true; + + intInp = alphabet.find(input); + output = _wiring[intInp]; + nextRot -> runThrough(output, false); + + return output; +} + +void Reflector::setWiring(int type){ + _rotorNo = type; + switch(type){ + case REFLECTOR_B: + _wiring = wiring_reflectorB; + break; + case REFLECTOR_B_THIN: + _wiring = wiring_reflectorB_thin; + break; + case REFLECTOR_C: + _wiring = wiring_reflectorC; + break; + case REFLECTOR_C_THIN: + _wiring = wiring_reflectorC_thin; + break; + default: + _wiring = alphabet; + break; + } +} diff --git a/EnigmaMachine/EnigmaMachine/Reflector.hpp b/EnigmaMachine/EnigmaMachine/Reflector.hpp new file mode 100644 index 0000000..f1a6ab0 --- /dev/null +++ b/EnigmaMachine/EnigmaMachine/Reflector.hpp @@ -0,0 +1,18 @@ +// +// Reflector.hpp +// EnigmaMachine +// +// Created by Ayush Agrawal on 11/07/20. +// Copyright © 2020 Ayush Agrawal. All rights reserved. +// + +#pragma once +#include "Rotor.hpp" + +class Reflector : public Rotor { +public: + Reflector(int type); + char runThrough(char input, bool forward); + void setWiring(int type); + void rotate() {}; +}; diff --git a/EnigmaMachine/EnigmaMachine/Rotor.cpp b/EnigmaMachine/EnigmaMachine/Rotor.cpp new file mode 100644 index 0000000..d0eaf10 --- /dev/null +++ b/EnigmaMachine/EnigmaMachine/Rotor.cpp @@ -0,0 +1,90 @@ +// +// Rotors.cpp +// EnigmaMachine +// +// Created by Ayush Agrawal on 10/07/20. +// Copyright © 2020 Ayush Agrawal. All rights reserved. +// + +#include "Rotor.hpp" + +Rotor::Rotor(int rotorNumber) { + _rotorNo = rotorNumber; + _offset = 0; + + prevRot = nullptr; + nextRot = nullptr; + + setWiring(_rotorNo); +} + +void Rotor::setWiring(int type){ + _rotorNo = type; + + switch(type) { + case ROTOR_1: + _wiring = wiring_rotor1; + _notch = rot1_notch; + break; + case ROTOR_2: + _wiring = wiring_rotor1; + _notch = rot2_notch; + break; + case ROTOR_3: + _wiring = wiring_rotor1; + _notch = rot3_notch; + break; + case ROTOR_4: + _wiring = wiring_rotor1; + _notch = rot4_notch; + break; + case ROTOR_5: + _wiring = wiring_rotor1; + _notch = rot5_notch; + break; + default: + _wiring = alphabet; + _notch = 'A'; + break; + } +} + +char Rotor::runThrough(char input, bool forward){ + int intInp; + char output; + + if (forward) { + intInp = alphabet.find(input); + intInp = (intInp + _offset) % 26; + output = _wiring[intInp]; + nextRot -> runThrough(output, true); + } else { + intInp = _wiring.find(input); + intInp = (intInp - _offset)%26; + if (intInp < 0){ + intInp += 26; + } + output = alphabet[intInp]; + if(prevRot != nullptr){ + prevRot -> runThrough(output, false); + } + } + + if (_wiring[_offset] == _notch){ + nextRot -> rotate(); + } + + return output; +} + +void Rotor::rotate(){ + _offset = (_offset + 1) % 26; +} + +int Rotor::position(){ + return _offset; +} + +void Rotor::setOffset(int num){ + _offset = num % 26; +} diff --git a/EnigmaMachine/EnigmaMachine/Rotor.hpp b/EnigmaMachine/EnigmaMachine/Rotor.hpp new file mode 100644 index 0000000..fb12f70 --- /dev/null +++ b/EnigmaMachine/EnigmaMachine/Rotor.hpp @@ -0,0 +1,37 @@ +// +// Rotors.cpp +// EnigmaMachine +// +// Created by Ayush Agrawal on 10/07/20. +// Copyright © 2020 Ayush Agrawal. All rights reserved. +// + +#pragma once + +#include "Utils/config.h" +#include "Utils/utils.hpp" + +#include + +class Rotor { +private: + int _offset; + char _notch; + +protected: + int _rotorNo; + std::string _wiring; + +public: + Rotor* nextRot; + Rotor* prevRot; + + Rotor(){ }; + Rotor(int rotorNumber); + virtual char runThrough(char input, bool forward); + virtual void rotate(); + int position(); + + virtual void setWiring(int type); + void setOffset(int num); +}; diff --git a/EnigmaMachine/EnigmaMachine/RotorSet.cpp b/EnigmaMachine/EnigmaMachine/RotorSet.cpp new file mode 100644 index 0000000..2c75562 --- /dev/null +++ b/EnigmaMachine/EnigmaMachine/RotorSet.cpp @@ -0,0 +1,82 @@ +// +// RotorSet.cpp +// EnigmaMachine +// +// Created by Ayush Agrawal on 11/07/20. +// Copyright © 2020 Ayush Agrawal. All rights reserved. +// + +#include "RotorSet.hpp" +#include +#include +#include + +RotorSet::RotorSet(int rot_nos[NO_OF_ROTORS], int reflectorType) { + for (int i = 0; i < NO_OF_ROTORS; i++){ + _rotors[i] = new Rotor(rot_nos[i]); + } + _reflector = new Reflector(reflectorType); + + for (int i = 0; i < NO_OF_ROTORS - 1; i++){ + _rotors[i]->nextRot = _rotors[i+1]; + _rotors[i+1]->prevRot = _rotors[i]; + } + + _rotors[NO_OF_ROTORS - 1]->nextRot = _reflector; + _reflector->nextRot = _rotors[NO_OF_ROTORS - 1]; +} + +RotorSet::~RotorSet(){ + for (int i = 0; i < NO_OF_ROTORS; i++){ + delete _rotors[i]; + } +} + +int RotorSet::parseValue(char input){ + char value = _rotors[0]->runThrough(input, true); + _rotors[0] -> rotate(); + + return value; +} + + +void RotorSet::setRotorOffset(int rotPos, int offset){ + if (rotPos >= NO_OF_ROTORS) return; + offset %= 26; + _rotors[rotPos]->setOffset(offset); + _config[rotPos][1] = offset; +} + +void RotorSet::setReflectorType(int type){ + _reflector->setWiring(type); + _config[NO_OF_ROTORS][0] = type; +} + +void RotorSet::setRotorType(int rotPos, int type){ + if (rotPos >= NO_OF_ROTORS) return; + _rotors[rotPos]->setWiring(type); + _config[rotPos][0] = type; + +} + +void RotorSet::randomConfig(){ + srand(time(0)); + int type; int offset; + std::set typesUsed; + + for (int i = 0; i < NO_OF_ROTORS; i++){ + offset = rand() % 26; + + do { + type = rand() % NO_ROTOR_TYPES; + } while (typesUsed.count(type) > 0); + + typesUsed.insert(type); + + setRotorType(i, type); + setRotorOffset(i, offset); + } + + type = rand() % NO_REFLECTOR_TYPES; + setReflectorType(type); +} diff --git a/EnigmaMachine/EnigmaMachine/RotorSet.hpp b/EnigmaMachine/EnigmaMachine/RotorSet.hpp new file mode 100644 index 0000000..6f8cec7 --- /dev/null +++ b/EnigmaMachine/EnigmaMachine/RotorSet.hpp @@ -0,0 +1,34 @@ +// +// RotorSet.hpp +// EnigmaMachine +// +// Created by Ayush Agrawal on 11/07/20. +// Copyright © 2020 Ayush Agrawal. All rights reserved. +// + +#pragma once + +#include "Rotor.hpp" +#include "Reflector.hpp" +#include + +#define NO_OF_ROTORS 3 + +class RotorSet { +private: + Rotor* _rotors[NO_OF_ROTORS]; + Rotor* _reflector; + + int _config[NO_OF_ROTORS+1][2]; + +public: + RotorSet(int rot_nos[NO_OF_ROTORS], int reflectorType); + ~RotorSet(); + int parseValue(char input); + + void setRotorOffset(int rotPos, int offset); + void setRotorType(int rotPos, int type); + void setReflectorType(int type); + + void randomConfig(); +}; diff --git a/EnigmaMachine/EnigmaMachine/Utils/config.h b/EnigmaMachine/EnigmaMachine/Utils/config.h new file mode 100644 index 0000000..f69fe5a --- /dev/null +++ b/EnigmaMachine/EnigmaMachine/Utils/config.h @@ -0,0 +1,69 @@ +// +// config.h +// EnigmaMachine +// +// Created by Ayush Agrawal on 10/07/20. +// Copyright © 2020 Ayush Agrawal. All rights reserved. +// + +#pragma once + +#include + +//Rotor names +#define ROTOR_1 0 +#define ROTOR_2 1 +#define ROTOR_3 2 +#define ROTOR_4 3 +#define ROTOR_5 4 + +#define REFLECTOR_B 0 +#define REFLECTOR_B_THIN 1 +#define REFLECTOR_C 2 +#define REFLECTOR_C_THIN 3 + +#define NO_ROTOR_TYPES 5 +#define NO_REFLECTOR_TYPES 4 + +//Rotor Wirings +//const int wiring_rotor1[][2] = { {0, 15}, {1, 4}, {2, 25}, {3, 20}, {4, 14}, {5, 7}, {6, 23}, {7, 18}, {8, 2}, +// {9, 21}, {10, 5}, {11, 12}, {12, 19}, {13, 1}, {14, 6}, {15, 11}, {16, 17}, {17, 8}, +// {18, 13}, {19, 16}, {20, 9}, {21, 22}, {22, 0}, {23, 24}, {24, 3}, {25, 10} }; +// +//const int wiring_rotor2[][2] = { {0, 25}, {1, 14}, {2, 20}, {3, 4}, {4, 18}, {5, 24}, {6, 3}, {7, 10}, {8, 5}, +// {9, 22}, {10, 15}, {11, 2}, {12, 8}, {13, 16}, {14, 23}, {15, 7}, {16, 12}, {17, 21}, +// {18, 1}, {19, 11}, {20, 6}, {21, 13}, {22, 9}, {23, 17}, {24, 0}, {25, 19} }; +// +//const int wiring_rotor3[][2] = { {0, 4}, {1, 7}, {2, 17}, {3, 21}, {4, 23}, {5, 6}, {6, 0}, {7, 14}, {8, 1}, +// {9, 16}, {10, 20}, {11, 18}, {12, 8}, {13, 12}, {14, 25}, {15, 5}, {16, 11}, {17, 24}, +// {18, 13}, {19, 22}, {20, 10}, {21, 19}, {22, 15}, {23, 3}, {24, 9}, {25, 2} }; +// +//const int wiring_rotor4[][2] = { {0, 8}, {1, 12}, {2, 4}, {3, 19}, {4, 2}, {5, 6}, {6, 5}, {7, 17}, {8, 0}, +// {9, 24}, {10, 18}, {11, 16}, {12, 1}, {13, 25}, {14, 23}, {15, 22}, {16, 11}, {17, 7}, +// {18, 10}, {19, 3}, {20, 21}, {21, 20}, {22, 15}, {23, 14}, {24, 9}, {25, 13} }; +// +//const int wiring_rotor5[][2] = { {0, 16}, {1, 22}, {2, 4}, {3, 17}, {4, 19}, {5, 25}, {6, 20}, {7, 8}, {8, 14}, +// {9, 0}, {10, 18}, {11, 3}, {12, 5}, {13, 6}, {14, 7}, {15, 9}, {16, 10}, {17, 15}, +// {18, 24}, {19, 23}, {20, 2}, {21, 21}, {22, 1}, {23, 13}, {24, 12}, {25, 11} }; +// +//const int wiring_reflector[][2] = { {0, 21}, {1, 10}, {2, 22}, {3, 17}, {4, 6}, {5, 8}, {6, 4}, {7, 19}, {8, 5}, +// {9, 25}, {10, 1}, {11, 20}, {12, 18}, {13, 15}, {14, 16}, {15, 13}, {16, 14}, {17, 3}, +// {18, 12}, {19, 7}, {20, 11}, {21, 0}, {22, 2}, {23, 24}, {24, 23}, {25, 9} }; + + +const std::string wiring_rotor1 = "EKMFLGDQVZNTOWYHXUSPAIBRCJ"; +const std::string wiring_rotor2 = "AJDKSIRUXBLHWTMCQGZNPYFVOE"; +const std::string wiring_rotor3 = "BDFHJLCPRTXVZNYEIWGAKMUSQO"; +const std::string wiring_rotor4 = "ESOVPZJAYQUIRHXLNFTGKDCMWB"; +const std::string wiring_rotor5 = "VZBRGITYUPSDNHLXAWMJQOFECK"; +const std::string wiring_reflectorB = "VZBRGITYUPSDNHLXAWMJQOFECK"; +const std::string wiring_reflectorC = "FVPJIAOYEDRZXWGCTKUQSBNMHL"; +const std::string wiring_reflectorB_thin = "ENKQAUYWJICOPBLMDXZVFTHRGS"; +const std::string wiring_reflectorC_thin = "RDOBJNTKVEHMLFCWZAXGYIPSUQ"; +const std::string alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + +const char rot1_notch = 'Q'; +const char rot2_notch = 'E'; +const char rot3_notch = 'V'; +const char rot4_notch = 'J'; +const char rot5_notch = 'Z'; diff --git a/EnigmaMachine/EnigmaMachine/Utils/utils.hpp b/EnigmaMachine/EnigmaMachine/Utils/utils.hpp new file mode 100644 index 0000000..e1d531c --- /dev/null +++ b/EnigmaMachine/EnigmaMachine/Utils/utils.hpp @@ -0,0 +1,32 @@ +// +// ArrayFunctions.hpp +// EnigmaMachine +// +// Created by Ayush Agrawal on 11/07/20. +// Copyright © 2020 Ayush Agrawal. All rights reserved. +// + +#pragma once +#include +#include +namespace custom_utils { + inline void copyArr2D(int arTo[26][2], const int arFrom[26][2], int size = 26){ + for (int i = 0; i < size; i++){ + for (int j = 0; j < 2; j++){ + arTo[i][j] = arFrom[i][j]; + } + } + } + + inline std::string removeSpace(std::string str){ + str.erase(remove_if(str.begin(), str.end(), isspace),str.end()); + + return str; + } + + inline std::string toUppercase(std::string str){ + std::transform(str.begin(), str.end(),str.begin(), ::toupper); + return str; + } + +} diff --git a/EnigmaMachine/EnigmaMachine/main.cpp b/EnigmaMachine/EnigmaMachine/main.cpp new file mode 100644 index 0000000..c3a84a9 --- /dev/null +++ b/EnigmaMachine/EnigmaMachine/main.cpp @@ -0,0 +1,23 @@ +// +// main.cpp +// EnigmaMachine +// +// Created by Ayush Agrawal on 10/07/20. +// Copyright © 2020 Ayush Agrawal. All rights reserved. +// + +#include +#include "EnigmaMachine.hpp" +#include "Utils/config.h" + +int main(int argc, const char * argv[]) { + int rotorNumbers[NO_OF_ROTORS] = {ROTOR_1, ROTOR_2, ROTOR_3}; + EnigmaMachine enigmaMachine(rotorNumbers, REFLECTOR_B); + int a; + + + std::cout << enigmaMachine.encode("NANANANANA BATMAN") << "\n"; + return 0; + + +}