Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 

Repository files navigation

tinyCaesar: A Caesar Cipher Implementation

Parameters

  • t: Input text to be encrypted or decrypted
  • n: Shift value (positive for encryption, negative for decryption)

Explanation

The tinyCaesar function uses:

  • Regular expressions (/[a-zA-Z]/g) to match all letters
  • A callback function (c => ...) to transform each matched letter
  • ASCII code manipulation (charCodeAt(0), String.fromCharCode(...)) for shifting
  • Modular arithmetic (% 26) to wrap around the alphabet

Example Usage

console.log(tinyCaesar("J", 3)); // Output: "M"

console.log(tinyCaesar("M", -3)); // Output: "J"

Key Points

  • Concise and efficient Caesar cipher implementation
  • Uses regular expressions and callback functions
  • Suitable for simple encryption/decryption tasks, but not recommended for sensitive data due to relative weakness

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages