Last active
February 8, 2018 20:24
-
-
Save nautical/4843a68ea41fa00d6617342c7f5e4532 to your computer and use it in GitHub Desktop.
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title></title> | |
</head> | |
<body> | |
<div id="enctest"></div> | |
</body> | |
<script type="text/javascript" src="//cdn.rawgit.com/ricmoo/aes-js/e27b99df/index.js"></script> | |
<script type="text/javascript"> | |
var enc = 'a7d93b35368519fac347498dec18b458'; | |
var repeat = [100,1000,10000,100000,200000]; | |
var key = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ]; | |
var aesEcb = new aesjs.ModeOfOperation.ecb(key); | |
</script> | |
<script type="text/javascript"> | |
var writer = function(t0,t1,length){ | |
var child = document.createElement('div'); | |
var _html = ((t1 - t0)/1000).toFixed(2) + "seconds : " + (length/1000000) + " Megabytes<br>"; | |
child.innerHTML = _html; | |
setTimeout(function(){ | |
document.getElementById('enctest').appendChild(child); | |
},20); | |
} | |
var runit = function(i){ | |
var ENC = enc.repeat(i); | |
var t0 = performance.now(); | |
var encryptedBytes = aesjs.utils.hex.toBytes(ENC); | |
var decryptedBytes = aesEcb.decrypt(encryptedBytes); | |
var decryptedText = aesjs.utils.utf8.fromBytes(decryptedBytes); | |
var t1 = performance.now(); | |
writer(t0,t1,ENC.length); | |
if(i<=100) console.log(decryptedText); | |
} | |
document.addEventListener('DOMContentLoaded', function() { | |
repeat.map(function(i){ | |
runit(i); | |
}) | |
}); | |
</script> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment