Created
January 24, 2019 04:25
-
-
Save dymurray/cf67a391d07c6076885060557e7f07ac 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
var EventSource = require("eventsource") | |
var datapay = require("datapay") | |
var source = new EventSource("https://genesis.bitdb.network/socket/1FnauZ9aUH2Bex6JzdcV4eNX7oLSSEbxtN/ewogICJ2IjogMywKICAicSI6IHsKICAgICJmaW5kIjogewogICAgICAib3V0LmgxIjogIjgwOGQiIAogICAgICAKICAgIH0KICB9LAogICJyIjogewogICAgImYiOiAiWy5bXSB8IC5vdXRbXSB8IHNlbGVjdCguYjAub3A/ID09IDEwNikgfCAuczJdIgogIH0KfQ==") | |
var ursa = require('ursa'); | |
var rsaKey = ursa.generatePrivateKey(1024, 65537); | |
var pubKey= ursa.createPublicKey(`-----BEGIN PUBLIC KEY----- | |
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAyQMEPLueD5bNUpELm61Z | |
kSmEuM99HT1eCw07YrOx6DzdliRNxfu8EIZ32NAkroWQCEdelgBaKpqzkxCyGeCt | |
2k67w0AGQHMKoxu5QarEk4sU84UzF9q+6P31q7fjP70dHFcQ/JibRF34Lbe+52Dl | |
/NGEzjwpvjvH4hX/2Sel0koNovIe/nOwIT+Dpbe2LObZncmkgICw5Zo9o9WU8hmu | |
AsxababciFsn+G9wWS06mWlTWaEVQ+7nJaMSfxUC2R13e6D53VJPuYg8Z4sNlmA7 | |
EX7KUpPhTDm0tEh4+6qphBi1mHSwJ7bP2DvxNcSr1DHN3gXl+9erFrNQlHrqcsDT | |
lQIDAQAB | |
-----END PUBLIC KEY-----`) | |
const privKey = "" | |
const message = JSON.stringify({signal: "attack", playerID: 123}) | |
var enc = pubKey.encrypt(message, 'utf8', 'base64') | |
console.log(enc.length) | |
console.log(Buffer.byteLength(enc, 'utf8')) | |
const tx = { | |
data: ["0x808d", enc], | |
pay: { key: privateKey } | |
} | |
datapay.build(tx, function(error, t) { | |
console.log(t) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment