Skip to content

Instantly share code, notes, and snippets.

View GregTonoski's full-sized avatar

Greg Tonoski GregTonoski

View GitHub Profile
@GregTonoski
GregTonoski / bxor.bash
Last active October 9, 2023 13:07
bxor.bash: bitwise exclusive OR (XOR) of two numbers represented in hexadecimal numerals
#!/bin/bash
# bxor.bash: bitwise exclusive OR (XOR) of two numbers represented in hexadecimal numerals. Result is padded with leading zeros if the number is smaller than 2**256.
# The script could be used to encrypt or decrypt (Vernam cipher).
# Examples:
# $ bash bxor.bash "000ffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364139" "fedc09"
# $ for i in {1..8}; do printf "%08X" "$SRANDOM" >> b256random.key; done && bash ./bxor.bash 012345b $( < b256random.key )
# $ head -c 32 /dev/random >> b256random.key && bash ./bxor.bash $( head -c 32 plaindata.bin | basenc --base16 -w 0 ) $( basenc --base16 -w 0 < b256random.key )
# $ zsh bxor.bash "ffff" "011"
# $ sh bxor.bash "ffff" "011"
@GregTonoski
GregTonoski / private_key_into_bitcoin_wif.sh
Last active January 5, 2025 03:25
Convert secp256k1 private key in hexadicimal number (HEX) to Bitcoin Wallet Import Format (WIF)
#!/bin/bash
# private_key_into_bitcoin_wif.sh: convert secp256k1 private key in hexadicimal number (HEX) to Bitcoin Wallet Import Format (WIF)
# Examples:
# $ bash private_key_into_bitcoin_wif.sh "000ffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364139" > private_key_bitcoin.wif
# $ bash private_key_into_bitcoin_wif.sh $(< input_file.txt) > private_key_bitcoin.wif
# $ cat priv_key.txt | xargs bash private_key_into_bitcoin_wif.sh > private_key_bitcoin.wif
# $ bash private_key_into_bitcoin_wif.sh fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364139 | echo "$(cat) importedkeylabel false" | xargs bitcoin-cli importprivkey && bitcoin-cli getaddressesbylabel importedkeylabel
# $ openssl rand -hex 32 | xargs bash private_key_into_bitcoin_wif.sh
# $ xxd -l 32 -p -c 32 /dev/random | xargs bash private_key_into_bitcoin_wif.sh