Coder Social home page Coder Social logo

caesar-cipher-stretch-lab's Introduction

Crypto-Crazy!

The name's Bond, James Bond. I need your help. I'm trying to get a message back to MI6 in London, but I'm nervous that the Soviets will be able to read what I'm saying and figure out my plans. I need your crack programming and cryptographic skills to ensure that this doesn't happen. A cipher is a disguised way of writing, a method of encrypting a message using an algorithm. Today you'll be writing the Caesar cipher.

The Caesar Cipher

The Caesar cipher takes in a number as a 'key' - let's call it k for key - and shifts the letters in the message k places away alphabetically. For example, if k = 3, the letter 'a' would shift three places to 'd', 'b' would shift three places to 'e', and so on. If you get to the end of alphabet and you need to keep shifting, you'd start at the end. So the letter 'x' shifted three places would be: 'x' => 'y' => 'z' => 'a'!

Changing the key would change the output, as it is a different number of places that you are shifting the alphabet. Capish?

Challenge One: Encrypt

Write a method caesar_encrypt that takes two arguments, a key and a phrase. Using the key, return the shifted phrase.

For example, calling caesar_encrypt(2, "Dog") will return "Fqi".

Challenge Two: Decrypt

You're now able to encrypt text using the Caesar cipher, but you also need to be able to decrypt text coming in from London. Write a method caesar_decrypt that takes in a key and a phrase, and deciphers the code.

For example, calling caesar_decrypt(2, "Fqi") will return "Dog".

Resources

caesar-cipher-stretch-lab's People

Contributors

aprietof avatar

Watchers

James Cloos 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.