<p>Bitcoin Core wallet encryption works by encrypting the private keys stored in the wallet file. The private keys are encrypted with a master key which is entirely random. This master key is then encrypted with AES-256-CBC with a key derived from the passphrase that you enter using SHA-512 and OpenSSL's EVP_BytesToKey and a dynamic number of rounds determined by the speed of the machine which does the initial encryption.</p>

<p>Now, the first wallet file contains private keys that were encrypted using your original passphrase. So, if you had backed up that file before changing the passphrase, then your old passphrase will work in unlocking that wallet. Thus you can spend the funds held in your original wallet.dat file with the old password.</p>

<p>However, the look-ahead keypool is refreshed so that any new addresses you request after the password change are not in the old wallet with the old private keys. This means that if you don't spend your bitcoins after you change your password, anyone with a copy of the original wallet with the old password can still steal your Bitcoin if they have the old password.</p>

CC BY-SA 4.0
2019-07-20T18:54:39.933Z
Can you take a look at my other question , and tell me if that makes sense ? 10x
in7ane
CC BY-SA 4.0
2019-07-20T18:57:13.280Z
@in7ane that question is already answered.
Ugam Kamat
CC BY-SA 4.0
2019-07-20T18:44:41.410Z
2019-07-20T18:44:41.410Z
Ugam Kamat
<p>What happens when i change the encryption password of Bitcoin-Core wallet?
Is first pass lost forever , where is it saved - on the blockchain or on the wallet.dat file? What if encrypt wallet with pass1 , save wallet.dat  , than change the password and encrypt it again with pass2  -  what will happen if i input the first wallet.dat with pass1 - can i unlock the wallet ?</p>

<bitcoin-core><encryption><passphrase>
What happens when i change the encryption password of Bitcoin-Core wallet
in7ane
# What happens when i change the encryption password of Bitcoin-Core wallet

(Asked by: username_0 on 2019-07-20)

What happens when i change the encryption password of Bitcoin-Core wallet?
Is first pass lost forever , where is it saved - on the blockchain or on the wallet.dat file? What if encrypt wallet with pass1 , save wallet.dat , than change the password and encrypt it again with pass2 - what will happen if i input the first wallet.dat with pass1 - can i unlock the wallet ?

**Tags:** bitcoin-core, encryption, passphrase


---

## 1 answers

### Answer by username_1 on 2019-07-20. Score: 1

Bitcoin Core wallet encryption works by encrypting the private keys stored in the wallet file. The private keys are encrypted with a master key which is entirely random. This master key is then encrypted with AES-256-CBC with a key derived from the passphrase that you enter using SHA-512 and OpenSSL's EVP\_BytesToKey and a dynamic number of rounds determined by the speed of the machine which does the initial encryption.

Now, the first wallet file contains private keys that were encrypted using your original passphrase. So, if you had backed up that file before changing the passphrase, then your old passphrase will work in unlocking that wallet. Thus you can spend the funds held in your original wallet.dat file with the old password.

However, the look-ahead keypool is refreshed so that any new addresses you request after the password change are not in the old wallet with the old private keys. This means that if you don't spend your bitcoins after you change your password, anyone with a copy of the original wallet with the old password can still steal your Bitcoin if they have the old password.

> **Comments:**
> **username_0**: Can you take a look at my other question , and tell me if that makes sense ? 10x  
> **username_1**: @username_0 that question is already answered.  

---

