2025-03-06 01:25:38 +01:00
|
|
|
import 'dart:convert';
|
|
|
|
|
|
|
|
import 'package:cake_wallet/.secrets.g.dart' as secrets;
|
|
|
|
import 'package:cw_core/wallet_base.dart';
|
|
|
|
import 'package:hashlib/hashlib.dart';
|
|
|
|
|
|
|
|
String createHashedWalletIdentifier(WalletBase wallet) {
|
2025-05-07 16:23:08 +01:00
|
|
|
if (wallet.seed == null || wallet.seed!.isEmpty) return '';
|
2025-03-06 01:25:38 +01:00
|
|
|
|
|
|
|
final salt = secrets.walletGroupSalt;
|
|
|
|
final combined = '$salt.${wallet.seed}';
|
|
|
|
|
|
|
|
// Convert to UTF-8 bytes.
|
|
|
|
final bytes = utf8.encode(combined);
|
|
|
|
|
|
|
|
// Perform SHA-256 hash.
|
|
|
|
final digest = sha256.convert(bytes);
|
|
|
|
|
|
|
|
// Return the hex string representation of the hash.
|
|
|
|
return digest.toString();
|
|
|
|
}
|