1
0
Fork 0

Create you ssb account from credentials ./zen/tools/make_G1SSB_secret.sh

This commit is contained in:
qo-op 2020-03-30 17:20:26 +02:00
parent 5e9468201f
commit bb9a1da3ce
6 changed files with 127 additions and 166 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

View File

@ -1,166 +0,0 @@
#!/usr/bin/python
# Image to HTML converter
# Copyright (C) January 2019 Neil Fraser
# https://neil.fraser.name/
# This program is free software; you can redistribute it and/or
# modify it under the terms of version 2 of the GNU General
# Public License as published by the Free Software Foundation.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# http://www.gnu.org/
# Loads JPEGs, PNGs and GIFs from websites and converts them to HTML.
# Usage: img2html.py?img=www.example.com/image.jpg
from PIL import Image
import cgi
import cStringIO
import math
import re
import sys
import urllib
# Throw a 500 error and terminate the program.
def die(msg):
print('Status:500')
print('Content-type: text/plain')
print('')
print('Error: ' + msg)
sys.exit()
def is_valid_url(url):
regex = re.compile(
r'^https?://' # http:// or https://
r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+[A-Z]{2,6}\.?|' # domain...
r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})' # ...or IP
r'(?::\d+)?' # optional port
r'(?:/?|[/?]\S+)$', re.IGNORECASE)
return url is not None and regex.search(url)
form = cgi.FieldStorage()
if not form.has_key('img'):
die('"img" paramater not found.')
#rows = min(512+1, int(form['y'].value, 10))
remoteurl = form['img'].value
remoteurl = remoteurl.strip()
if not remoteurl:
die('No image URL specified.')
if not re.match('\\w+:\/\/', remoteurl):
remoteurl = 'http://' + remoteurl
if not is_valid_url(remoteurl):
die('Invalid image URL. Please go back and check the address.')
# Reduce load on my server, use cached tux.html if the request is tux.jpg
if remoteurl == 'https://neil.fraser.name/software/img2html/tux.jpg':
f = open('/home/neil/html/software/img2html/tux.html')
print("Content-type: text/html\n\n")
print(f.read())
f.close()
sys.exit()
try:
f = urllib.urlopen(remoteurl)
data = f.read()
except Exception as err:
die('Invalid image URL: %s' % err)
oldsize = int(round(len(data) / 1024))
cStr = cStringIO.StringIO(data)
image = Image.open(cStr)
image = image.convert('RGBA')
background = Image.new('RGBA', image.size, (255, 255, 255))
background.paste(image, mask=image.split()[3]) # 3 is the alpha channel
image = background
image = image.convert('RGB')
maxPixels = 100*100
(oldX, oldY) = image.size
if oldX * oldY > maxPixels:
factor = math.sqrt(maxPixels / float(oldX * oldY))
newX = int(round(oldX * factor))
newY = int(round(oldY * factor))
image.thumbnail((newX, newY), Image.ANTIALIAS)
msg = '[This image is too large to comfortably handle, so it has been scaled down to %s%% of its original size.]<P>' % int(100.0 * newX / oldX);
else:
newX = oldX
newY = oldY
msg = ''
# Scan the image pixel by pixel and build the HTML table.
table = '';
firstrow = True # Disable RLE for first row of each table segment (dodge Mozilla bug)
for y in range(newY):
row = '';
for x in range(newX):
try:
(r, g, b) = image.getpixel((x, y))
except:
# Some images throw a range error on some (transparent?) pixels.
(r, g, b) = (255, 255, 255)
if x == newX:
# Dummy run to clear the colspan buffer.
rgb = ''
else:
rgb = '%02x%02x%02x' % (r, g, b)
if x == 0: # Initialise the RLE (Run Length Encoding)
prev_rgb = rgb
span = 0
span += 1
if rgb != prev_rgb or firstrow:
if span == 1: # One pixel.
row += "<TD BGCOLOR=#%s><img width=1 height=1></TD>" % prev_rgb
else: # A run of multiple pixels with the same colour.
row += "<TD BGCOLOR=#%s COLSPAN=%d><img width=1 height=1></TD>" % (prev_rgb, span)
span = 0
prev_rgb = rgb
table += "<TR>%s</TR>\n" % row
# Segment the table so that MSIE renders it in pieces instead of waiting till the end.
if y != 0 and (y == 5 or y % 15 == 0) and y < newY - 10:
table += "</TABLE><TABLE CELLPADDING=0 CELLSPACING=0 BORDER=0>\n"
firstrow = True
else:
firstrow = False
newsize = int(round(len(table) / 1024))
# We're done. Now print it all out (this is what takes the time).
print("Content-type: text/html\n")
print("""
<HTML>
<HEAD>
<TITLE>img2html: {remoteurl}</TITLE>
</HEAD>
<BODY>
<DL>
<DT><B>Original Image</B>
<DD><A HREF="{remoteurl}">{remoteurl}</A>
<DD>{oldX}x{oldY}
<DD>{oldsize}KB
<P>
{msg}
<DT><B>Text Image</B>
<DD>{newX}x{newY}
<DD>{newsize}KB
<DD>
<TABLE CELLPADDING=0 CELLSPACING=0 BORDER=0>
{table}</TABLE>
<P>
<DT><B>Done</B>
</DL>
</BODY></HTML>
""".format(remoteurl=remoteurl, table=table, msg=msg,
oldsize=oldsize, newsize=newsize,
oldX=oldX, oldY=oldY, newX=newX, newY=newY))

0
zen/tools/install.ssb-npm.sh Normal file → Executable file
View File

28
zen/tools/key_create_dunikey.py Executable file
View File

@ -0,0 +1,28 @@
#!/usr/bin/env python3
# This Python script gets Duniter creddentials as arguments, and writes a PubSec file that should be compatible with Cesium and Silkaj(DuniterPy) clients.
# launch with :
# python3 key_create_dnuikey.py <id> <mdp>
# depends on duniterpy 0.56
### Licence - WTFPL
# This script was written my Matograine, in the hope that it will be helpful.
# Do What The Fuck you like with it. There is :
# * no guarantee that this will work
# * no support of any kind
#
# If this is helpful, please consider making a donation to the developper's pubkey : 78ZwwgpgdH5uLZLbThUQH7LKwPgjMunYfLiCfUCySkM8
# Have fun
from sys import argv
from duniterpy.key import SigningKey
# path to save to
path = "./.secret.dunikey"
key = SigningKey.from_credentials(argv[1], argv[2], None)
key.save_pubsec_file(path)
print(
"G1 Wallet: ",
key.pubkey,
)

99
zen/tools/make_G1SSB_secret.sh Executable file
View File

@ -0,0 +1,99 @@
#!/bin/bash
########################################################################
MY_PATH="`dirname \"$0\"`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
ME="${0##*/}"
echo '
########################################################################
# \\///
# qo-op
############# '$MY_PATH/$ME'
########################################################################
# Make a G1SSB Account
########################################################################
'
if [[ -d ~/.ssb ]]; then
echo "ScuttelButt is already installed..."
echo "Do you want to remove ~/.ssb ? (y)/n"
read isitok
if [[ "$isitok" == "y" ]]; then rm -Rf ~/.ssb; else echo "You must remove '~/.ssb' before running $ME"; exit 1; fi
fi
mkdir -p ~/.ssb
echo "WELCOME CREATING YOUR G1 SSB ACCOUNT !!!"
echo '
__ __ __ _
/__ /| (_ (_ |_)
\_| | __) __) |_)
CHOOSE YOU LOGIN or LEAVE BLANK & HIT ENTER FOR AUTO GENERATION
'
read salt
[[ $salt != "" ]] && echo "CHOOSE PASSWORD?" && read pepper && [[ $pepper == "" ]] && exit 1
if [[ "$salt" == "" && "$pepper" == "" ]]; then
echo '
._ _ ._ _ ._ _ _ ._ o _
| | | | | (/_ | | | (_) | | | (_
passphrase generator...'
# GENERATE MNEMONIC KEY: 9 MOTS
# LOGIN (=SALT) 6 WORDS
salt="$($MY_PATH/diceware.sh 6)"
# PASS (=PEPPER) 3 WORDS
pepper="$($MY_PATH/diceware.sh 3)"
echo "........."
echo "REMEMBER YOUR CREDENTIALS !!!
login (salt) : $salt
password : $pepper"
fi
# CREATE ~/.ssb/secret.dunikey
python3 $MY_PATH/key_create_dunikey.py "$salt" "$pepper"
mv $MY_PATH/.secret.dunikey ~/.ssb/secret.dunikey
# CREATE SSB secret
pub=$(cat ~/.ssb/secret.dunikey | grep "pub" | cut -d ' ' -f 2)
priv=$(cat ~/.ssb/secret.dunikey | grep "sec" | cut -d ' ' -f 2)
ssbpub=$(echo $pub | base58 -d | base64)
ssbpriv=$(echo $priv | base58 -d | base64)
cat > ~/.ssb/secret <<EOF
# This secret is related to your G1Wallet - https://cesium.app
# silkaj balance $pub
# ID (salt): $salt / Pass: $pepper
# THIS KEY IS YOURS! REMIND IT AND KEEP IT SAFE AS A REAL WALLET
# chmod 400 ~/.zen/secret
{
"curve": "ed25519",
"public": "$ssbpub.ed25519",
"private": "$ssbpriv.ed25519",
"id": "@$ssbpub.ed25519"
}
# WARNING! It's vital that you DO NOT edit OR share your secret name
# instead, share your public name
# your SSB public name: @$ssbpub.ed25519
EOF
echo "
_
|__|_ \ / _ o | _.
|_ |_ \/ (_) | | (_|
Your G1SSB KEY is made !!
# Social App
Install Patchwork : https://github.com/ssbc/patchwork/releases/
# Libre Money Wallet
Use your credential with https://cesium.app
login (salt) : $salt
password : $pepper
"
exit 0