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 C++ string methods.

Easy

2 Hours

High 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 use C++ string methods in order to sort and shift characters to encode and decode your messages.