Coder Social home page Coder Social logo

c-plus-plus-exercises's Introduction

C++ Coding Exercises

RSA Decrypter

Program to decrypt public-key RSA (for small keys). Created for a programming challenge.

  • Step 1: Given a ciphertext (c), modulus (N) and encryption key (e), decompose N into two primes, p and q

  • Step 2: Calculate the totient function (phiN), phiN = (p - 1) * (q - 1)

  • Step 3: Calculate the decryption key (d) using the modular inverse, d = e^(-1) * mod(phiN)

  • Step 4: Find the plaintext message using modular exponentiation, plainText = C^(n) * mod(N)

  • Step 5: Convert the plaintext to hexadecimal then print as an ASCII string

Inputs (hex-encoded):

ciphertext (c)
modulus (N)
encryption key (e)

Output:

Prints decrypted output message as a string

Sources used for RSA:

  Erickson, J. (2008). Hacking: the art of exploitation. No starch press.
  Schneier, B. (2007). Applied cryptography: protocols, algorithms, and source code in C. john wiley & sons.
  Schneier, B., Kohno, T., & Ferguson, N. (2013). Cryptography engineering: design principles and practical applications. Wiley.

Magic Numbers

Program to check if input numbers are 'magic numbers'.

There are 2 conditions for a magic number:

    No digits repeat.
    Beginning with the leftmost digit, take the value of the digit and move that number of digits to the right. Repeat the process again using the value of the current digit to move right again. Wrap back to the leftmost digit as necessary. A magic number will visit every digit exactly once and end at the leftmost digit.

Inputs:

Two integers on a line, separated by spaces. Each integer A and B is 1 <= A <= B <= 10000.

Output:

Prints each magic number between A and B, inclusive. If there is no magic number between A and B, print -1.

c-plus-plus-exercises's People

Contributors

zcostello avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.