Giter Site home page Giter Site logo

encryption-code-challenges's Introduction

Encryption Code Challenges

Team up with a partner and pick a code challenge. You will spend 15 minutes solving it individually. After 15 minutes - even if you are not finished - you will spend 10 minutes reviewing review each other's code. Some things to discuss...

  • Approach
  • Where you got stuck
  • Opportunities for refactoring

Maskify

For security purposes, you rarely want to show somebody's full credit card or social security number online. Instead, you usually display only the last four digits and hide the rest (e.g., ************1234).

Define a method that takes in a string. It should return a string which leaves the final four characters untouched, while the rest are converted to asterisks.

maskify("12345678")
# => "****5678"

maskify("18240981253")
# => "*******1253"

maskify("my dog's name is fido")
# => "*****************fido"

If the method is fed a string shorter than 4 characters, return the string as is.

maskify("123")
# => "123"

Caesar Cipher II

Define a method that, given a string (str), returns a string in which each letter is incremented by some number (num). So, if num = 2, "a" turns into "c" and "x" turns into "z").

caesar("abcd", 5)
# => "fghi"

caesar("hello", 2)
# => "jgnnq"
Hint...
One approach is to generate a numerical representation of a character and manipulate that. Google something along the lines of "javascript character unicode".

Bonus

The method should ignore any character that is not a letter.

caesar("hello, world.", 2)
# => "jgnnq, yqtnf."

Atbash Cipher

Define a method that, given a string (str), returns a string in which each character is converted to its inverse. For example, "c" (the third letter in the alphabet) should be converted to "x" (third-to-last letter). Or "y" (second-to-last) should be converted to "b" (second).

atbash("abcd")
# => "zyxw"

atbash("hello")
# => "svool"

It might help to include the following somewhere in your code...

alphabet = "abcdefghijklmnopqrstuvwxyz".to_a

You can learn more about the Atbash Cipher here.

encryption-code-challenges's People

Contributors

amaseda 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.