diff --git a/.gitignore b/.gitignore index 7cb3b64..c31e826 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ www/LOVELand/jukebox/prefs www/LOVELand/jukebox/albumart www/LOVELand/g1barre/img/qrcodes zen/tools/scraping/transiscope/transiscope.json +zen/tools/__pycache__ diff --git a/zen/tools/__pycache__/crypto_pb2.cpython-36.pyc b/zen/tools/__pycache__/crypto_pb2.cpython-36.pyc deleted file mode 100644 index ba72c32..0000000 Binary files a/zen/tools/__pycache__/crypto_pb2.cpython-36.pyc and /dev/null differ diff --git a/zen/tools/create_ipfsnodeid_from_tmp_secret.dunikey.py b/zen/tools/create_ipfsnodeid_from_tmp_secret.dunikey.py index 86ded7c..167b691 100755 --- a/zen/tools/create_ipfsnodeid_from_tmp_secret.dunikey.py +++ b/zen/tools/create_ipfsnodeid_from_tmp_secret.dunikey.py @@ -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 diff --git a/zen/tools/ipfs_to_g1.py b/zen/tools/ipfs_to_g1.py new file mode 100755 index 0000000..f34b750 --- /dev/null +++ b/zen/tools/ipfs_to_g1.py @@ -0,0 +1,10 @@ +#!/usr/bin/env python3 + +import sys, base58 + +ID = sys.argv[1] +hexFmt = base58.b58decode(ID) +noTag = hexFmt[6:] +b58Key = base58.b58encode(noTag).decode() + +print(b58Key)