Page MenuHomec4science

test-medco-crypto-web.go
No OneTemporary

File Metadata

Created
Thu, Aug 8, 23:00

test-medco-crypto-web.go

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