Wednesday, November 6, 2024

pockets restoration – How can I discover a Bitcoin non-public key that I saved in a textual content file?

In case you’re programming savvy you may write a small program that searches for the common expression of a Bitcoin non-public key. Bitcoin non-public keys have a really particular format:

They’re 51 keys lengthy, begin with a ‘5’ and the second letter is both ‘H’, ‘J’, or ‘Okay’ and use base58 for the remaining 49 letters which excludes the characters 0IOl.

It appears to me that the next common expression ought to work to search out an uncompressed non-public key:
5[HJK][1-9A-HJ-NP-Za-km-z]{49} (inspiration: Stackoverflow).

Later, one other format was launched for compressed keys, which has 52 base58 characters, and begins with a ‘Okay’ or ‘L’. For that format, it’s best to be capable to use the next common expression:

[KL][1-9A-HJ-NP-Za-km-z]{51}

Notice that common expressions can use barely various syntax, so that you may must adapt the expression to the programming language or instrument that you just use. You’ll be able to generate just a few non-public keys, e.g. with bitaddress.org for testing materials. It is best to in all probability be simpler should you embody phrase boundary b symbols earlier than and after the expression.

In case you’re on a Unix system, these grep instructions would discover uncompressed and compressed non-public keys recursively from the listing you are calling from:

grep -r 'b5[HJK][1-9A-HJ-NP-Za-km-z]{49}b' *
grep -r 'b[KL][1-9A-HJ-NP-Za-km-z]{51}b' *

Or seek for each of them with this mixed sample:

grep -r 'b[5KL][1-9A-HJ-NP-Za-km-z]{50,51}b' *

To make use of grep on Home windows, you may maybe discover a answer right here: What are good grep instruments for Home windows?

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles