https://ift.tt/5IcYPbu line to create Bitcoin Wallet (same logic from BitAddress.org)

Command line to create Bitcoin Wallet (same logic from BitAddress.org)

https://ift.tt/KABdJjF


I had the need to create a script that I can run on any computer offline to generate bitcoin wallets based on a password. I’m posting it here in case it’s helpful to anyone.

Script for Bash (must install `openssl` and `base58`):

“`
PASSWORD=”my-passphrase-here”; printf “nBitcoin WalletnnPassword:n$PASSWORDnnPrivate Key:n$(printf “0000000000000000000000000000000000000000000000000000000000000000$(openssl ec -inform DER -text -noout -in <(printf “302e0201010420$(printf “$PASSWORD” | sha256sum | sed ‘s/[^a-z0-9]//g’)a00706052b8104000a” | xxd -r -ps) 2>/dev/null | tail -10 | head -3 | sed ‘s/[ :]//g’ | tr -d ‘n’)” | sed ‘s/.*(.{64}$)/1/’)nnPrivate Key, WIF:n$(printf “$(printf “80$(printf “0000000000000000000000000000000000000000000000000000000000000000$(openssl ec -inform DER -text -noout -in <(printf “302e0201010420$(printf $PASSWORD | openssl sha256 | sed ‘s/^.*s//g’)a00706052b8104000a” | xxd -r -ps) 2>/dev/null | tail -10 | head -3 | sed ‘s/[ :]//g’ | tr -d ‘n’)” | sed ‘s/.*(.{64}$)/1/’)”)$(printf “80$(printf “0000000000000000000000000000000000000000000000000000000000000000$(openssl ec -inform DER -text -noout -in <(printf “302e0201010420$(printf “$PASSWORD” | openssl sha256 | sed ‘s/^.*s//g’)a00706052b8104000a” | xxd -r -ps) 2>/dev/null | tail -10 | head -3 | sed ‘s/[ :]//g’ | tr -d ‘n’)” | sed ‘s/.*(.{64}$)/1/’)” | xxd -r -ps | openssl sha256 | sed ‘s/^.*s//g’ | awk ‘ORS=” “‘ | sed ‘s/W//g’ | xxd -r -ps | openssl sha256 | sed ‘s/^.*s//g’ | awk ‘ORS=” “‘ | sed ‘s/W//g’ | sed ‘s/(.{8}).*/1/’)” | xxd -r -ps | base58)nnPublic Key:n$(openssl ec -inform DER -text -noout -in <(printf “302e0201010420$(printf “$PASSWORD” | sha256sum | sed ‘s/[^a-z0-9]//g’)a00706052b8104000a” | xxd -r -ps) 2>/dev/null | tail -6 | head -5 | sed ‘s/[ :]//g’ | tr -d ‘n’)nnPublic Key, Wallet:n$(printf “$(printf “00$(openssl ec -inform DER -text -noout -in <(printf “302e0201010420$(printf “$PASSWORD” | openssl sha256 | sed ‘s/^.*s//g’)a00706052b8104000a” | xxd -r -ps) 2>/dev/null | tail -6 | head -5 | sed ‘s/[ :]//g’ | tr -d ‘n’ | xxd -r -ps | openssl sha256 | sed ‘s/^.*s//g’ | awk ‘ORS=” “‘ | sed ‘s/W//g’ | xxd -r -ps | openssl ripemd160 | sed ‘s/.*s//’ | awk ‘ORS=” “‘ | sed ‘s/W//g’)”)$(printf “00$(openssl ec -inform DER -text -noout -in <(printf “302e0201010420$(printf “$PASSWORD” | openssl sha256 | sed ‘s/^.*s//g’)a00706052b8104000a” | xxd -r -ps) 2>/dev/null | tail -6 | head -5 | sed ‘s/[ :]//g’ | tr -d ‘n’ | xxd -r -ps | openssl sha256 | sed ‘s/^.*s//g’ | awk ‘ORS=” “‘ | sed ‘s/W//g’ | xxd -r -ps | openssl ripemd160 | sed ‘s/.*s//’ | awk ‘ORS=” “‘ | sed ‘s/W//g’)” | xxd -r -ps | openssl sha256 | sed ‘s/^.*s//g’ | awk ‘ORS=” “‘ | sed ‘s/W//g’ | xxd -r -ps | openssl sha256 | sed ‘s/^.*s//g’ | awk ‘ORS=” “‘ | sed ‘s/W//g’ | sed ‘s/(.{8}).*/1/’)” | xxd -r -ps | base58)nn”
“`

![Bash output](https://ift.tt/UGft9qm)

View post on imgur.com

Script for PowerShell (must install `openssl`):

“`
$password=”my-passphrase-here”; $tempFile=”./temp”; [System.IO.File]::WriteAllText($tempFile, $password); $passwordSha256=$(openssl sha256 $tempFile | Select-String “[0-9a-f]{64}”).Matches[0].Value; $passwordSha256Secp256k1=”302e0201010420${passwordSha256}a00706052b8104000a”; [System.IO.File]::WriteAllBytes($tempFile, [System.Convert]::FromHexString($passwordSha256Secp256k1)); $keys=$($(openssl ec -inform DER -text -noout -in $tempFile | Select-String “(?<=^s+)[0-9a-f:]+”).Matches | Select-Object -Property Value | ForEach-Object -Process {$_.Value.Replace(“:”, “”)}); $keyPrivate=$keys[0]+$keys[1]+$keys[2]; $keyPublic=$keys[3]+$keys[4]+$keys[5]+$keys[6]+$keys[7]; [System.IO.File]::WriteAllBytes($tempFile, [System.Convert]::FromHexString($keyPublic)); $keyPublicSha256=$(openssl sha256 $tempFile | Select-String “[0-9a-f]{64}”).Matches[0].Value; [System.IO.File]::WriteAllBytes($tempFile, [System.Convert]::FromHexString($keyPublicSha256)); $keyPublicSha256Ripemd160=$(openssl ripemd160 $tempFile | Select-String “[0-9a-f]{40}”).Matches[0].Value; $keyPublicSha256Ripemd160Prefixed=”00″+$keyPublicSha256Ripemd160; [System.IO.File]::WriteAllBytes($tempFile, [System.Convert]::FromHexString($keyPublicSha256Ripemd160Prefixed)); $keyPublicSha256Ripemd160Checksum=$(openssl sha256 $tempFile | Select-String “[0-9a-f]{64}”).Matches[0].Value; [System.IO.File]::WriteAllBytes($tempFile, [System.Convert]::FromHexString($keyPublicSha256Ripemd160Checksum)); $keyPublicSha256Ripemd160Checksum=$(openssl sha256 $tempFile | Select-String “[0-9a-f]{64}”).Matches[0].Value.Substring(0, 8); $bitcoinKeyPublic=”$keyPublicSha256Ripemd160Prefixed$keyPublicSha256Ripemd160Checksum”; $keyPrivatePrefixed=”80″+$keyPrivate.PadLeft(64, ‘0’); [System.IO.File]::WriteAllBytes($tempFile, [System.Convert]::FromHexString($keyPrivatePrefixed)); $keyPrivateChecksum=$(openssl sha256 $tempFile | Select-String “[0-9a-f]{64}”).Matches[0].Value; [System.IO.File]::WriteAllBytes($tempFile, [System.Convert]::FromHexString($keyPrivateChecksum)); $keyPrivateChecksum=$(openssl sha256 $tempFile | Select-String “[0-9a-f]{64}”).Matches[0].Value.Substring(0, 8); $bitcoinKeyPrivate=”$keyPrivatePrefixed$keyPrivateChecksum”; function Base58 { param ([parameter(valuefrompipeline=$true)] [string]$1) $i=[bigint]::Parse($1,”AllowHexSpecifier”); $chars=@(); $index =@(‘1′,’2′,’3′,’4′,’5′,’6′,’7′,’8′,’9′,’A’,’B’,’C’,’D’,’E’,’F’,’G’,’H’,’J’,’K’,’L’,’M’,’N’,’P’,’Q’,’R’,’S’,’T’,’U’,’V’,’W’,’X’,’Y’,’Z’,’a’,’b’,’c’,’d’,’e’,’f’,’g’,’h’,’i’,’j’,’k’,’m’,’n’,’o’,’p’,’q’,’r’,’s’,’t’,’u’,’v’,’w’,’x’,’y’,’z’); if (($1).length % 2 -ne 0 -OR $i -lt 0) { $1=”0$1″; $i=[bigint]::Parse($1, “AllowHexSpecifier”); } while($i -gt 0) { $m=([bigInt]$i % 58); $i=([bigInt]$i / 58); $chars+=$index[$m]; } [array]::reverse($chars); $i=$chars -join (”); $1 -split “(..)” | ForEach-Object { if ($_ -match “00”) { $i=(“1″+$i); } else { return; } }; $chars=@(); $chars.clear(); $index=@(); $index.clear(); return $i; }; $bitcoinKeyPrivateBase58=Base58($bitcoinKeyPrivate); $bitcoinKeyPublicBase58=Base58($bitcoinKeyPublic); [System.IO.File]::Delete($tempFile); Write-Output “Bitcoin Wallet`n`nPassword:`n$password`n`nPrivate Key:`n$keyPrivate`n`nPrivate Key, WIF:`n$bitcoinKeyPrivateBase58`n`nPublic Key:`n$keyPublic`n`nPublic Key, Wallet:`n$bitcoinKeyPublicBase58`n`n”
“`

![PowerShell output](https://ift.tt/Cn58olJ)

View post on imgur.com

Other prints here: [imgur.com/a/lPTBH2T](https://ift.tt/mHBhPzV)

View Reddit by sergiocabralView Source

Cryptocurrency

Get In Touch