SecretWallet.encode constructor
Creates a new wallet wrapping the specified credentials
by encrypting
the private key with the password
. The random
instance, which should
be cryptographically secure, is used to generate encryption keys.
You can configure the parameter N of the scrypt algorithm if you need to.
The default value for scryptN
is 8192. Be aware that this N must be a
power of two.
using a separate thread for encode or decode secret wallet.
Implementation
factory SecretWallet.encode(
String credentials,
String password, {
int scryptN = 8192,
int p = 1,
}) {
final passwordBytes = Uint8List.fromList(utf8.encode(password));
// final dartRandom = RandomBridge(random);
final salt = generateRandom(32);
final derivator = _ScryptKeyDerivator(32, scryptN, 8, p, salt);
final uuid = UUID.toBuffer(UUID.generateUUIDv4());
final iv = generateRandom(128 ~/ 8);
return SecretWallet._(credentials, derivator, passwordBytes, iv, uuid);
}