Skip to content

Commit

Permalink
fix: Use hex to avoid unexpected string. (nervosnetwork#3162)
Browse files Browse the repository at this point in the history
  • Loading branch information
yanguoyu authored May 21, 2024
1 parent bc4977f commit 286f199
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/neuron-wallet/src/services/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export default class SettingsService extends Store {

private generateEncryptString(str: string) {
if (safeStorage.isEncryptionAvailable()) {
return safeStorage.encryptString(str).toString('utf-8')
return safeStorage.encryptString(str).toString('hex')
}
const hash = crypto.createHash('sha256')
hash.update(str)
Expand All @@ -108,6 +108,9 @@ export default class SettingsService extends Store {
}

verifyLockWindowPassword(password: string) {
if (safeStorage.isEncryptionAvailable()) {
return safeStorage.decryptString(Buffer.from(this.lockWindowInfo.encryptedPassword!, 'hex')) === password
}
const encryptedPassword = this.generateEncryptString(password)
return SettingsService.getInstance().lockWindowInfo.encryptedPassword === encryptedPassword
}
Expand Down

0 comments on commit 286f199

Please sign in to comment.