Created
March 31, 2020 20:11
-
-
Save MauricioSilv/989d45fe5746366a531b2e734339dee6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const axios = require('axios'); | |
class getdataController{ | |
async index(req, res){ | |
try { | |
const response = await axios.get('https://api.codenation.dev/v1/challenge/dev-ps/generate-data?token=TOKEN'); | |
const { cifrado } = response.data; | |
var new_message = ""; | |
for(const letra of cifrado){ | |
let message = letra.charCodeAt(0); | |
if(message >= 97 && message <= 122){ | |
let msg = message - response.data.numero_casas; | |
if(new_message < 97){ | |
new_message += String.fromCharCode(122 - (96 - msg)) | |
}else{ | |
new_message += String.fromCharCode(msg); | |
} | |
}else{ | |
new_message += String.fromCharCode(message); | |
} | |
} | |
console.log(new_message); | |
} catch (error) { | |
console.log(error); | |
} | |
} | |
} | |
module.exports = new getdataController(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment