Use python only, no bash anymore ...

This commit is contained in:
poka 2020-12-08 17:05:04 +01:00
parent a1ad3390d8
commit 042e66a091
1 changed files with 8 additions and 8 deletions

View File

@ -8,19 +8,19 @@
# protoc --python_out=. crypto.proto
#########################################################################
import os
import base58
import base64
import re, base58, base64, crypto_pb2
import cryptography.hazmat.primitives.asymmetric.ed25519 as ed25519
from cryptography.hazmat.primitives import serialization
import crypto_pb2
from sys import argv
# TODO controls
# Capturing keys (from /tmp/secret.dunikey)
shared_key = os.popen('cat /tmp/secret.dunikey | grep pub | cut -d " " -f 2').read()
secure_key = os.popen('cat /tmp/secret.dunikey | grep sec | cut -d " " -f 2').read()
dunikey = "/tmp/secret.dunikey"
for line in open(dunikey, "r"):
if re.search("pub", line):
shared_key = line.replace('\n','').split(': ')[1]
elif re.search("sec", line):
secure_key = line.replace('\n','').split(': ')[1]
# Decoding keys
decoded_shared = base58.b58decode(shared_key)
@ -46,7 +46,7 @@ pkey = crypto_pb2.PrivateKey()
pkey.Type = 1
pkey.Data = ipfs_secure_bytes + ipfs_shared_bytes
PrivKey = base64.b64encode(pkey.SerializeToString()).decode('ascii')
print('PrivKEY={}'.format(base64.b64encode(pkey.SerializeToString()).decode('ascii')))
print('PrivKEY=' + base64.b64encode(pkey.SerializeToString()).decode('ascii'))
# jq '.Identity.PeerID="$PeerID"' ~/.ipfs/config
# jq '.Identity.PrivKey="$PrivKey"' ~/.ipfs/config