Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F86262883
test-medco-crypto-web.go
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
Sat, Oct 5, 09:20
Size
1 KB
Mime Type
text/x-c
Expires
Mon, Oct 7, 09:20 (2 d)
Engine
blob
Format
Raw Data
Handle
21357510
Attached To
R2664 SHRINE MedCo Fork
test-medco-crypto-web.go
View Options
package
main
import
(
"time"
"strconv"
"github.com/gopherjs/gopherjs/js"
"github.com/JoaoAndreSa/MedCo/lib"
)
//var cothorityPublicKey string
/**
* Encapsulate the library in the cryptoJS object that you can
* find the global JS object
*/
func
main
()
{
// js.Global.Set("cryptoJSmedcotest", map[string]interface{}{
// "IntToPoint": lib.IntToPoint,
// "EncryptInt": lib.EncryptInt,
// "GenKey": lib.GenKey,
// "Javascript name": gopkg.gofunc,
// })
t
:=
time
.
Now
()
js
.
Global
.
Get
(
"document"
).
Call
(
"getElementById"
,
"testtext1"
).
Set
(
"innerHTML"
,
"modif from go - "
+
t
.
Format
(
"20060102150405"
))
valueEncTest
:=
int64
(
888
)
t
=
time
.
Now
()
js
.
Global
.
Get
(
"document"
).
Call
(
"getElementById"
,
"testtext2"
).
Set
(
"innerHTML"
,
"generating keys... - "
+
t
.
Format
(
"20060102150405"
))
secKey
,
pubKey
:=
lib
.
GenKey
()
t
=
time
.
Now
()
js
.
Global
.
Get
(
"document"
).
Call
(
"getElementById"
,
"testtext3"
).
Set
(
"innerHTML"
,
"keys gen, encrypting... - "
+
t
.
Format
(
"20060102150405"
))
encInt
:=
lib
.
EncryptInt
(
pubKey
,
valueEncTest
)
t
=
time
.
Now
()
js
.
Global
.
Get
(
"document"
).
Call
(
"getElementById"
,
"testtext4"
).
Set
(
"innerHTML"
,
"encrypted, decrypting... - "
+
t
.
Format
(
"20060102150405"
))
decInt
:=
lib
.
DecryptInt
(
secKey
,
*
encInt
)
t
=
time
.
Now
()
js
.
Global
.
Get
(
"document"
).
Call
(
"getElementById"
,
"testtext5"
).
Set
(
"innerHTML"
,
"value:"
+
strconv
.
FormatInt
(
decInt
,
10
)
+
" - "
+
t
.
Format
(
"20060102150405"
))
}
Event Timeline
Log In to Comment