Please enable JavaScript to use CodeHS

Shift Cipher with String Methods

In this project, students will create a shift cipher that encodes and decodes messages using JavaScript string methods.

Medium

2 Hours

High School

Middle School

Project Description

Background

A shift cipher is a basic way to encrypt messages. Each letter of the alphabet is assigned to another letter of the alphabet based on a shift value.


Shift Cipher Key Example


For example, an encrypted message has a shift value of -2: AMBCFQ
When the message is decrypted, it reads: CODEHS


Your Task

You’ll create a program that encrypts and decrypts a user-entered message by using a shift value to reassign the letters. The full decrypted or encrypted message is then printed to the console. You’ll need to use functions with parameters, user inputs, returns, print to the console, and pass arguments when calling functions.