Skip to content

Working encoder #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
Binary file added EnigmaMachine/.DS_Store
Binary file not shown.
312 changes: 312 additions & 0 deletions EnigmaMachine/EnigmaMachine.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,312 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 50;
objects = {

/* Begin PBXBuildFile section */
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 */
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 = "<group>"; };
64FDE09024B8E48E003D1B0D /* EnigmaMachine.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = EnigmaMachine.cpp; sourceTree = "<group>"; };
64FDE09124B8E48E003D1B0D /* EnigmaMachine.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = EnigmaMachine.hpp; sourceTree = "<group>"; };
64FDE09724B8F57E003D1B0D /* RotorSet.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = RotorSet.cpp; sourceTree = "<group>"; };
64FDE09824B8F57E003D1B0D /* RotorSet.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = RotorSet.hpp; sourceTree = "<group>"; };
64FDE0A224B925CF003D1B0D /* Rotor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Rotor.cpp; sourceTree = "<group>"; };
64FDE0A324B925CF003D1B0D /* Rotor.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Rotor.hpp; sourceTree = "<group>"; };
64FDE0A624B926DC003D1B0D /* config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = config.h; sourceTree = "<group>"; };
64FDE0A724B926DC003D1B0D /* utils.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = utils.hpp; sourceTree = "<group>"; };
/* 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 = "<group>";
};
64FDE08724B8E42F003D1B0D /* Products */ = {
isa = PBXGroup;
children = (
64FDE08624B8E42F003D1B0D /* EnigmaMachine */,
);
name = Products;
sourceTree = "<group>";
};
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 */,
);
path = EnigmaMachine;
sourceTree = "<group>";
};
64FDE0A524B926DC003D1B0D /* Utils */ = {
isa = PBXGroup;
children = (
64FDE0A624B926DC003D1B0D /* config.h */,
64FDE0A724B926DC003D1B0D /* utils.hpp */,
);
path = Utils;
sourceTree = "<group>";
};
/* 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 */,
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 */;
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>EnigmaMachine.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
</dict>
</plist>
35 changes: 35 additions & 0 deletions EnigmaMachine/EnigmaMachine/EnigmaMachine.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//
// 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]): _rotorSet(rot_nos) {
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 charIn = (char) inpCopy[i];
int intIn = _intCharMap.find( charIn );
int intOut = _rotorSet.parseValue( intIn );
char charOut = _intCharMap[intOut];

outputStr.push_back(charOut);
}

return outputStr;
}
Loading