forked from qo-op/G1BILLET
Première version de G1BILLET
parent
3ad8fd1cd0
commit
621abe2352
|
@ -0,0 +1,46 @@
|
|||
#!/bin/bash
|
||||
################################################################################
|
||||
# Author: Fred (support@qo-op.com)
|
||||
# Version: 0.1
|
||||
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
|
||||
################################################################################
|
||||
MY_PATH="`dirname \"$0\"`" # relative
|
||||
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
|
||||
ME="${0##*/}"
|
||||
################################################################################
|
||||
# Create and print 6 G1Billets de $MONTANT DU
|
||||
# ${MY_PATH}/G1BILLETS.sh 5 986397643
|
||||
################################################################################
|
||||
MONTANT="$1"
|
||||
UNIQID="$2"
|
||||
|
||||
[[ $MONTANT == "" ]] && MONTANT=1
|
||||
[[ $UNIQID == "" ]] && UNIQID=$(date -u +%s%N | cut -b1-13)
|
||||
|
||||
# CREATION DE 6 BILLETS DE $MONTANT DU
|
||||
NBbillets=6
|
||||
boucle=0;
|
||||
while [ $boucle -lt $NBbillets ]
|
||||
do
|
||||
boucle=$((boucle+1))
|
||||
NUMBER=$(${MY_PATH}/diceware.sh 4 | xargs)
|
||||
SECRET=$(${MY_PATH}/diceware.sh 4 | xargs)
|
||||
|
||||
bpath=$(echo $NUMBER | sed 's/ /_/g')
|
||||
|
||||
# CREATION CLEF BILLET
|
||||
BILLETPUBKEY=$(python3 ${MY_PATH}/key_create_dunikey.py "$NUMBER" "$SECRET")
|
||||
rm -f /tmp/secret.dunikey
|
||||
|
||||
mkdir -p "/tmp/g1billet/${UNIQID}"
|
||||
# CREATION FICHIER IMAGE BILLET
|
||||
$(${MY_PATH}/G1BILLET_MAKE.sh "${NUMBER}" "${SECRET}" "${MONTANT}" "${BILLETPUBKEY}" "${UNIQID}")
|
||||
|
||||
done
|
||||
|
||||
# MONTAGE DES IMAGES DES BILLETS VERS /tmp/g1billet/${UNIQID}.pdf
|
||||
montage /tmp/g1billet/${UNIQID}/*.jpg -tile 2x3 -geometry 964x459 /tmp/g1billet/${UNIQID}.pdf
|
||||
# NB!! if "not autorized" then edit /etc/ImageMagick-6/policy.xml and comment
|
||||
# <!-- <policy domain="coder" rights="none" pattern="PDF" /> -->
|
||||
|
||||
exit
|
|
@ -0,0 +1,78 @@
|
|||
#!/bin/bash
|
||||
################################################################################
|
||||
# Author: Fred (support@qo-op.com)
|
||||
# Version: 0.1
|
||||
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
|
||||
################################################################################
|
||||
# INSTALLER convert et qrencode: sudo apt install imagemagick qrencode
|
||||
################################################################################
|
||||
MY_PATH="`dirname \"$0\"`" # relative
|
||||
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
|
||||
ME="${0##*/}"
|
||||
############################################################################################################################################################
|
||||
# ${MY_PATH}/G1BILLET_MAKE.sh "nu me ro test" "se cr et" 100 7sn9dKeCNEsHmqm1gMWNREke4YAWtNw8KG1YBSN8CmSh 97968583
|
||||
############################################################################
|
||||
|
||||
NUMERO="$1"
|
||||
SECRET="$2"
|
||||
MONTANT="$3"
|
||||
NOTERIB="$4"
|
||||
UNIQID="$5"
|
||||
|
||||
if [[ "$NUMERO" == "" || "$SECRET" == "" || "$MONTANT" == "" || "$NOTERIB" == "" || "$UNIQID" == "" ]]
|
||||
then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mkdir -p /tmp/g1billet/$UNIQID
|
||||
BILLETNAME=$(echo $NUMERO | sed 's/ /_/g')
|
||||
|
||||
# Add ${MY_PATH}/images/logo.png (250px)
|
||||
composite -compose Over -gravity SouthWest -geometry +50+50 -dissolve 70% "${MY_PATH}/images/logo.png" "${MY_PATH}/images/fond.jpg" "/tmp/${BILLETNAME}.jpg"
|
||||
|
||||
# Prepare BILLET qrcode verification URL
|
||||
qrencode -s 6 -o "/tmp/g1billet/${UNIQID}/${BILLETNAME}.QR.png" "$NOTERIB"
|
||||
|
||||
# Add verification QRCode
|
||||
composite -compose Over -gravity NorthEast -geometry +50+25 "/tmp/g1billet/${UNIQID}/${BILLETNAME}.QR.png" "/tmp/${BILLETNAME}.jpg" "/tmp/${BILLETNAME}.jpg"
|
||||
|
||||
# Change June logo color
|
||||
case "$MONTANT" in
|
||||
1)
|
||||
convert "${MY_PATH}/images/g1.png" -fuzz 20% -fill grey -opaque '#e5912b' "/tmp/g1.png"
|
||||
;;
|
||||
2)
|
||||
convert "${MY_PATH}/images/g1.png" -fuzz 20% -fill green -opaque '#e5912b' "/tmp/g1.png"
|
||||
;;
|
||||
5)
|
||||
convert "${MY_PATH}/images/g1.png" -fuzz 20% -fill orange -opaque '#e5912b' "/tmp/g1.png"
|
||||
;;
|
||||
10)
|
||||
convert "${MY_PATH}/images/g1.png" -fuzz 20% -fill blue -opaque '#e5912b' "/tmp/g1.png"
|
||||
;;
|
||||
20)
|
||||
convert "${MY_PATH}/images/g1.png" -fuzz 20% -fill purple -opaque '#e5912b' "/tmp/g1.png"
|
||||
;;
|
||||
50)
|
||||
convert "${MY_PATH}/images/g1.png" -fuzz 20% -fill red -opaque '#e5912b' "/tmp/g1.png"
|
||||
;;
|
||||
100)
|
||||
convert "${MY_PATH}/images/g1.png" -fuzz 20% -fill black -opaque '#e5912b' "/tmp/g1.png"
|
||||
;;
|
||||
*)
|
||||
cp "${MY_PATH}/images/g1.png" "/tmp/g1.png"
|
||||
;;
|
||||
esac
|
||||
|
||||
# Add June LOGO to Billet
|
||||
composite -compose Over -gravity SouthEast -geometry +20+20 -dissolve 90% "/tmp/g1.png" "/tmp/${BILLETNAME}.jpg" "/tmp/${BILLETNAME}.jpg"
|
||||
|
||||
convert -font 'Liberation-Sans' \
|
||||
-pointsize 120 -fill black -draw 'text 250,250 "'"$MONTANT DU"'"' \
|
||||
-pointsize 35 -fill black -draw 'text 100,60 "'"G1 BILLET"'"' \
|
||||
-pointsize 30 -draw 'text 50,100 "'"Identifiant: $NUMERO"'"' \
|
||||
-pointsize 22 -fill black -draw 'text 50,130 "'"Code Secret: $SECRET"'"' \
|
||||
-pointsize 22 -fill black -draw 'text 150,440 "'"Porte Monnaie Libre!! Utiliser avec https://cesium.app"'"' \
|
||||
"/tmp/${BILLETNAME}.jpg" "/tmp/g1billet/${UNIQID}/${BILLETNAME}.BILLET.jpg"
|
||||
|
||||
rm -f /tmp/${BILLETNAME}.jpg
|
38
README.md
38
README.md
|
@ -1,4 +1,38 @@
|
|||
# G1BILLET
|
||||
|
||||
Générateur de G1BILLETS
|
||||
Utilisable en ligne de commande (ou sur un site web)
|
||||
## Présentation
|
||||
Ce code est un générateur de G1BILLETS
|
||||
|
||||
Il lance la fabrication de six "G1 Portefeuilles" vides à remplir soi-même !
|
||||
Les G1Billets sont assemblés dans un fichier PDF pour les imprimer facilement sur une imprimante A4
|
||||
|
||||
Avant de vous en servir, utilisez Cesium pour flasher le QR Code et effectuer le virement correspondant à son montant sur chaque portefeuille.
|
||||
Ensuite, offrez ces G1 Billets à qui vous voulez.
|
||||
Son détenteur peut alors utiliser l'identifiant/mot de passe secret (diceware) pour accéder au portefeuille correspondant.
|
||||
|
||||
|
||||
## Utilisation
|
||||
Pour une utilisation en ligne de commande, adaptez ces quelques lignes
|
||||
|
||||
```
|
||||
Montant=5 # Valeur faciale à indiquer sur le billet
|
||||
NomFichier="nom_unique_du_pdf" # Correspond au nom du fichier créé dans /tmp/g1billet/
|
||||
./G1BILLETS.sh "$Montant" "$NomFichier"
|
||||
```
|
||||
|
||||
Pour personnaliser vos G1Billets, modifiez les images dans le répertoire du même nom (en conservant les dimensions)
|
||||
La fabrication de la planche de G1Billets depuis un site web...
|
||||
|
||||
## Installation
|
||||
|
||||
Avant de pouvoir utiliser ce code, vous devez installer ces logiciels
|
||||
|
||||
```
|
||||
sudo apt install imagemagick qrencode
|
||||
pip3 install duniterpy
|
||||
```
|
||||
|
||||
NB: Si une erreur du type "not autorized" apparait, vous devez autoriser la création de pdf en editant /etc/ImageMagick-6/policy.xml pour commenter la ligne:
|
||||
``
|
||||
<!-- <policy domain="coder" rights="none" pattern="PDF" /> -->
|
||||
```
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,20 @@
|
|||
#!/usr/bin/env bash
|
||||
# Download the wordlist
|
||||
# wget -nc -O ~/.diceware-wordlist http://world.std.com/%7Ereinhold/diceware.wordlist.asc 2> /dev/null
|
||||
MY_PATH="`dirname \"$0\"`" # relative
|
||||
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
|
||||
ME="${0##*/}"
|
||||
MOTS=$(echo "$1" | grep -E "^\-?[0-9]+$")
|
||||
# Default to 6 words passphrase
|
||||
if [[ "$MOTS" == "" ]]; then MOTS=6; fi
|
||||
WORDCOUNT=${1-$MOTS}
|
||||
# print a list of the diceware words
|
||||
cat ${MY_PATH}/diceware-wordlist.txt |
|
||||
awk '/[1-6][1-6][1-6][1-6][1-6]/{ print $2 }' |
|
||||
# randomize the list order
|
||||
shuf --random-source=/dev/urandom |
|
||||
# pick the first n words
|
||||
head -n ${WORDCOUNT} |
|
||||
# pretty print
|
||||
tr '\n' ' '
|
||||
echo
|
Binary file not shown.
After Width: | Height: | Size: 120 KiB |
Binary file not shown.
After Width: | Height: | Size: 33 KiB |
Binary file not shown.
After Width: | Height: | Size: 77 KiB |
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
if ( ! isset($_REQUEST['montant']) ) {
|
||||
$_REQUEST['montant'] = "5";
|
||||
}
|
||||
$mytime = new Datetime("now");
|
||||
$timestamp = $mytime->format('U');
|
||||
|
||||
// CREATE 6 G1BILLETS in /tmp/g1billet/$timestamp
|
||||
shell_exec("./G1BILLETS.sh $_REQUEST['montant'] $timestamp");
|
||||
|
||||
$attachment_location = "/tmp/g1billet/".$timestamp.".pdf";
|
||||
if (file_exists($attachment_location)) {
|
||||
header($_SERVER["SERVER_PROTOCOL"] . " 200 OK");
|
||||
header("Cache-Control: public"); // needed for internet explorer
|
||||
header("Content-Type: application/pdf");
|
||||
header("Content-Transfer-Encoding: Binary");
|
||||
header("Content-Length:".filesize($attachment_location));
|
||||
header("Content-Disposition: attachment; filename=".$timestamp.".pdf");
|
||||
readfile($attachment_location);
|
||||
die();
|
||||
} else {
|
||||
die("Error: File not found.");
|
||||
}
|
||||
?>
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
#!/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 = "/tmp/secret.dunikey"
|
||||
|
||||
key = SigningKey.from_credentials(argv[1], argv[2], None)
|
||||
key.save_pubsec_file(path)
|
||||
print(
|
||||
key.pubkey,
|
||||
)
|
Loading…
Reference in New Issue