Difference between revisions of "Team:Groningen/Coding"

Line 37: Line 37:
 
</head>
 
</head>
 
<body>
 
<body>
<h1>Encryption</h1>
+
<h2>Encryption</h2>
 
 
 
<hr />
 
<hr />
Line 46: Line 46:
 
</div>
 
</div>
 
<div id="cnt-message">
 
<div id="cnt-message">
<h2>Message</h2>
+
<h3>Message</h3>
 
 
 
<textarea id="msg">Hello world</textarea>
 
<textarea id="msg">Hello world</textarea>
 
</div>
 
</div>
 
<div id="cnt-key">
 
<div id="cnt-key">
<h2>Key</h2>
+
<h3>Key</h3>
 
 
 
<textarea id="key">secret</textarea>
 
<textarea id="key">secret</textarea>
Line 69: Line 69:
 
 
 
<div id="cnt-transform">
 
<div id="cnt-transform">
<h2 id="cur">Plain text</h2>
+
<h3 id="cur">Plain text</h3>
 
 
 
<textarea id="enc"></textarea>
 
<textarea id="enc"></textarea>
Line 116: Line 116:
 
elStage = document.getElementById('stage');
 
elStage = document.getElementById('stage');
 
 
var subCoding = EightBit, doCrypt = false, lastEdit = elMsg,
+
var cryptBits = 256, stages = [
cryptBits = 256, stages = [
+
 
{name: "Plain text", description: "A message that has not "+
 
{name: "Plain text", description: "A message that has not "+
 
"been encrypted is called 'plain text'. The first "+
 
"been encrypted is called 'plain text'. The first "+
Line 205: Line 204:
 
], current;
 
], current;
 
 
function advanceStage(prev){
+
var stg = new Stager(stages, elCur, elDesc, elEnc, elKey);
var idx = prev ? prev.idx : 0,
+
stg.init(elMsg, elStage);
cur = stages[idx],
+
data = prev.data,
+
disp;
+
+
if(!cur){
+
return cur;
+
}
+
+
if(cur.transform){
+
data = cur.transform(data);
+
}
+
+
disp = data;
+
if(cur.display){
+
disp = cur.display(data);
+
}
+
+
return {stage: cur, idx: (idx + 1) % stages.length, data: data, display: disp};
+
}
+
+
function showStage(){
+
current = advanceStage(current);
+
+
elEnc.value = current.display;
+
elCur.innerHTML = current.stage.name;
+
elDesc.innerHTML = current.stage.description;
+
}
+
+
function resetStage(){
+
console.log(current);
+
current = {idx: 0, data: null, display: null};
+
showStage();
+
}
+
+
elMsg.oninput = elMsg.onkeyup = resetStage;
+
elKey.oninput = elKey.onkeyup = resetStage;
+
elStage.onclick = showStage;
+
+
resetStage();
+
 
</script>
 
</script>
 
</body>
 
</body>
 
</html>
 
</html>
 
{{Groningen/footer}}
 
{{Groningen/footer}}

Revision as of 13:00, 3 October 2016

CryptoGE®M
Team
Project
Biology
Computing
Human Practice
Acknowledgements

SpyGEM coding

Encryption


Enter the message you want to secure here

Message

Key

Enter your secret key/password here


Plain text


Oop top