UNPKG

cloud-ide-lms-model

Version:

Package for Model management of Cloud IDEsys LMS

25 lines (24 loc) 997 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.customEncrypt = customEncrypt; exports.customDecrypt = customDecrypt; // Custom encryption function function customEncrypt(plainPassword) { let encryptedPassword = ''; for (let i = 0; i < plainPassword.length; i++) { // Shift ASCII value of each character forward by 1 const encryptedCharCode = plainPassword.charCodeAt(i) + 1; // Shift forward by 1 encryptedPassword += String.fromCharCode(encryptedCharCode); } return encryptedPassword; } // Custom decryption function function customDecrypt(encryptedPassword) { let decryptedPassword = ''; for (let i = 0; i < encryptedPassword.length; i++) { // Shift ASCII value of each character back by the same amount const decryptedCharCode = encryptedPassword.charCodeAt(i) - 1; // Shift back by 1 decryptedPassword += String.fromCharCode(decryptedCharCode); } return decryptedPassword; }