under corrupted_wif put my private with the missing character and left "should be" empty like ' '
the file is on my desktop under folder called BTC1
This is what i had copied
import bitcoin.base58
from bitcoin.core import b2x, x
from bitcoin.wallet import CBitcoinSecret, P2PKHBitcoinAddress
from bitcoin.core import Hash
def insert_char(string, char, i):
return string[:i+1]+char+string[i+1:]
def verify_wif_checksum(wif):
byte_string = b2x(bitcoin.base58.decode(wif))
private = byte_string[:-8]
checksum = byte_string[-8:]
return checksum == b2x(Hash(x(private)))[:8]
def candidate_wifs(corrupted_wif):
candidates = []
for i in range(len(corrupted_wif)):
for char in bitcoin.base58.B58_DIGITS:
candidate_wif = insert_char(corrupted_wif, char, i)
if verify_wif_checksum(candidate_wif):
candidates.append(candidate_wif)
return candidates
# Provide a WIF private key with a single missing character.
corrupted_wif = '5HueCGU8rMjxEXxiPuD5BDku4kFqeZyd4dZ1jvhTVqvbTLvyTJ'
# Should be: ''
for candidate_wif in candidate_wifs(corrupted_wif):
print(candidate_wif)
failed please help - can't open file 'corrupt_wif.py': [Errno 2] No such file or directory cannot open file
Did you actually copy/paste
the code from the earlier post into a file and did you name that file corrupt_wif.py?

If so, where is that file?