Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F112011282
example.html
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Tue, May 6, 19:29
Size
2 KB
Mime Type
text/html
Expires
Thu, May 8, 19:29 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
25999472
Attached To
R4897 i2b2-webclient
example.html
View Options
<meta charset="UTF-8">
<head>
<title>JS encryption tests</title>
<script type="text/javascript" src="cryptolib.js"></script>
<script>
var counter = 0;
setInterval(()=> {
counter += 1;
document.querySelector("#mydiv").innerHTML = counter;
}, 100);
var pk=null,sk;
var cipher, plain;
var K, S;
function genkey(){
[sk, pk] = GenKey()
// alert("Secret key: " + sk + "\nPrivate key: " + pk)
}
function encrypt(){
cipher = EncryptInt(pk, 9999)
// alert("Cipher: " + cipher)
}
function decrypt() {
plain = DecryptInt(cipher, sk);
alert("Plaintext: " + plain)
}
function light_encrypt_init(){
if (pk==null){
alert("generate the keys before")
}
[K, S] = LightEncryptInt_init(pk)
}
function light_encrypt(){
cipher = LightEncryptInt(9999, K, S)
}
function enc10(){
genkey();
light_encrypt_init(pk);
var start = Date.now()
var plains = [13, 66, 23444, -124523632, 151, 5552, 352, -12426324634];
for(var i=0; i < plains.length; i++){
setTimeout(()=>LightEncryptInt(i, K, S), i*100)
}
alert((Date.now()-start)/1000 + " seconds to encrypt " + plains.length + " integers")
}
async function enc_async(i, K, S){
return await LightEncryptInt(i, K, S)
}
</script>
</head>
<body>
<div id="mydiv"></div>
<input type="button" onclick="genkey()" value="gen key">
<input type="button" onclick="encrypt()" value="encrypt 5000">
<input type="button" onclick="decrypt()" value="decrypt">
<input type="button" onclick="genkey();encrypt();decrypt()" value="all">
<!--<input type="button" onclick="MyPrint()" value="print">-->
<br>
<input type="button" onclick="light_encrypt_init()" value="light enc init">
<input type="button" onclick="light_encrypt()" value="light enc 5000">
<br>
<input type="button" onclick="enc10()" value="light enc 10 numbers">
</body>
</html>
Event Timeline
Log In to Comment