Skip to content

Instantly share code, notes, and snippets.

View nhtranngoc's full-sized avatar

Nam Tran Ngoc nhtranngoc

View GitHub Profile
@nhtranngoc
nhtranngoc / substitution_cipher.c
Last active October 28, 2019 01:56
Quick C program to solve Prof. Mus' cipher
/*
ECE4802 - Cryptography
Homework 1
Part 1
Nam Tran Ngoc
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/*
ECE4802 - Cryptography
Homework 1
Part 2
Nam Tran Ngoc
*/
#include <stdio.h>
#include <stdint.h>
@nhtranngoc
nhtranngoc / out.txt
Last active November 1, 2019 03:16
Part 2 Output
./a.out
0: 0101 1000 0
1: 0010 1100 0
2: 0001 0110 0
3: 0000 1011 1
4: 0000 0101 1
5: 0000 0010 0
6: 0000 0001 1
7: 1000 0000 0
@nhtranngoc
nhtranngoc / des.out
Created November 5, 2019 18:19
Output of DES encrypter (first pass)
INPUT
1 1 0 0 0 1 0 0
0 0 1 0 1 0 0 0
0 1 0 1 0 0 0 0
0 1 1 0 1 0 0 1
EXPANSION
1 1 1 0 0 0
0 0 1 0 0 0
0 0 0 1 0 1
@nhtranngoc
nhtranngoc / mod.c.out
Created November 9, 2019 02:57
ECE4802 HW2 Part 2
15*29 mod 13 = 6
15*29 mod 12 = 3
15*28 mod 12 = 0
(15*29+7*12) mod 13 = 12
5^-1 mod 19 = 4
5^-1 mod 12 = 5
5^-1 mod 17 = 3
5^-1 mod 10 = -1
@nhtranngoc
nhtranngoc / CMakeLists.txt
Created June 13, 2020 21:36
Yart's main CMakeLists
cmake_minimum_required(VERSION 3.10)
project(yart)
enable_language(C CXX)
if(CMAKE_CROSSCOMPILING)
message(STATUS "Crosscompiling enabled, using toolchain file: ${CMAKE_TOOLCHAIN_FILE}")
add_subdirectory(src)
else()
message(STATUS "No crosscompiling specified, compiling in /tests only.")
@nhtranngoc
nhtranngoc / arm_none_eabi_toolchain.cmake
Created June 14, 2020 00:27
Yart - Cross compiling arm toolchain file
set(CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY")
set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_PROCESSOR arm)
set(CMAKE_CROSSCOMPILING TRUE)
set(CMAKE_C_COMPILER arm-none-eabi-gcc)
set(CMAKE_CXX_COMPILER arm-none-eabi-g++)
set(OBJCOPY arm-none-eabi-objcopy)
@nhtranngoc
nhtranngoc / CMakeLists.txt
Last active June 14, 2020 00:42
yart - CMakelist for stm32 target
make_minimum_required(VERSION 3.10)
set(LDSCRIPT "${CMAKE_SOURCE_DIR}/stm32f429i-discovery.ld")
set(LIBNAME "opencm3_stm32f4")
add_definitions(-DSTM32F4)
set(FP_FLAGS "-mfloat-abi=hard -mfpu=fpv4-sp-d16")
set(ARCH_FLAGS "-mthumb -mcpu=cortex-m4 ${FP_FLAGS}")
set(OPENCM3_DIR "${CMAKE_SOURCE_DIR}/lib/libopencm3")
@nhtranngoc
nhtranngoc / CMakeLists.txt
Created June 14, 2020 00:54
yart - CMakeLists for tests
cmake_minimum_required(VERSION 3.10)
if(DEFINED ENV{CPPUTEST_HOME})
message(STATUS "Using CppUTest home: $ENV{CPPUTEST_HOME}")
set(CPPUTEST_INCLUDE_DIRS $ENV{CPPUTEST_HOME}/include)
set(CPPUTEST_LIBRARIES $ENV{CPPUTEST_HOME}/build/lib)
set(CPPUTEST_LDFLAGS CppUTest CppUTestExt)
else()
find_package(PkgConfig REQUIRED)
@nhtranngoc
nhtranngoc / right_angled_triangle.c
Last active August 6, 2020 03:29
Program to check if input numbers are Pythagorean triplets.
// Written by Nam Tran Ngoc
#include <stdio.h>
#include <stdlib.h>
int main() {
unsigned int a, b, c;
printf("Please enter three positive integers as sides of a triangle, separated between spaces: \n");
scanf("%d %d %d", &a, &b, &c);