Last active
September 2, 2017 01:43
-
-
Save patmigliaccio/96b07e80ca0f66cae25e4ead01e37f34 to your computer and use it in GitHub Desktop.
patmigliaccio.com/client-side-security 7/27/17
This file contains 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
function requestGeneratedSVG(){ | |
return xhr('/assets/css/svg/generate') | |
.then(response => { | |
let content = parseSVGResponse(response.data); | |
// Decoded sensitive data would be handled here. | |
return JSON.parse(atob(content)); | |
}); | |
} | |
// Note: Unnecessary complexity added to logic to increase level of ambiguity. | |
function parseSVGResponse(data){ | |
// Puts the last 64 chars in the front. | |
let dataAry = data.split(''); | |
for (let i = 0; i < 64; i++) { | |
let lastChars = dataAry.pop().trim(); | |
dataAry.unshift(lastChars); | |
} | |
// Reverses the order of the string. | |
let dataOut = []; | |
dataAry.forEach(x => dataOut.unshift(x)) | |
return dataOut.join(''); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment