Bitcoin Forum

Bitcoin => Project Development => Topic started by: cilphex on May 24, 2013, 03:20:16 AM



Title: Regular expression for private key base 58?
Post by: cilphex on May 24, 2013, 03:20:16 AM
I'm writing a bitcoin app and would like to validate addresses somehow.  I found this regex for public addresses:

/^[13n][1-9A-Za-z][^OIl]{20,40}/

But I'm looking for one for base 58 private keys as well.  (Base 58 is the import format right?)

I don't know a lot about the rules for these keys/addresses.  If I did I'd just write the regexes myself.  Any help is much appreciated.


Title: Re: Regular expression for private key base 58?
Post by: jackjack on May 24, 2013, 03:00:37 PM
Is that regex working? I'd put some parentheses

/^5[1-9A-Za-z][^OIl]{20,50}/
or
/^5([1-9A-Za-z][^OIl]){20,50}/

Try with some private keys from https://www.bitaddress.org/