Skip to content

Instantly share code, notes, and snippets.

@patmigliaccio
Created September 2, 2017 01:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save patmigliaccio/ef5ceb5be02a42db5271e60556e23d64 to your computer and use it in GitHub Desktop.
Save patmigliaccio/ef5ceb5be02a42db5271e60556e23d64 to your computer and use it in GitHub Desktop.
patmigliaccio.com/client-side-security 7/27/17
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