This repository contains two JavaScript functions that demonstrate a simple way to encrypt and decrypt text using ASCII character codes. The encryption function takes a string as input, shifts each character's ASCII value by 5, and returns an encrypted string. The decryption function reverses this process, shifting each character's ASCII value back by 5 to retrieve the original text.
- Encrypt text by shifting each character's ASCII value by 5
- Decrypt encrypted text by reversing the shift
- Easy to understand and implement
- Basic knowledge of JavaScript
function encrypt(text)
This function takes a string text
as input and encrypts it by shifting each character's ASCII value by 5. The encrypted text is then logged to the console.
function decrypt(text)
This function takes an encrypted string text
as input and decrypts it by shifting each character's ASCII value back by 5. The decrypted text is then logged to the console.
- Copy the
encrypt
anddecrypt
functions into your JavaScript code. - Call the
encrypt
function with a string you want to encrypt, e.g.,encrypt("Hello")
. - The encrypted text will be logged to the console.
- Call the
decrypt
function with the encrypted text to retrieve the original text, e.g.,decrypt("Mjqqt")
. - The decrypted text will be logged to the console.
This simple encryption and decryption method is not secure and should not be used for protecting sensitive data. It is meant for educational purposes and as an introduction to basic encryption concepts. For secure encryption, consider using more advanced encryption algorithms like AES or RSA.
This code is not licensed and is free for public use.