You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
final pbkdf2 = Pbkdf2(
macAlgorithm: Hmac(sha256),
iterations: 100000,
bits: 128,
);
final nonce = Nonce(base64Decode('EQsBDQcMBQEWBAsaFBkUEQ=='));
print(nonce);
final hashBytes = await pbkdf2.deriveBits(
utf8.encode('Lorem ipsum dolor sit amet, consetetur...'),
nonce: nonce,
);
print('Hash: $hashBytes');
String result = utf8.decode(hashBytes); <----- **HOW DO I CONVERT THIS TO STRING? NEED A STRING FORMAT.**
print(result);
i got an error when i tried to use utf8.decode to decode the hashBytes.
any other way to convert to string? or this a bug? please help. thanks
PBDKF2 returns raw data. It isn't encoded in UTF-8 and as such can't be used with utf8.decode().
If you want to have a String you have to encode the data. Standart is to either use Hex encoding which turns every byte in two chars or to use Base64 which turns every 3 bytes to 4 chars.
So the final line could look like String result = base64Encode(hashBytes)
i got an error when i tried to use utf8.decode to decode the hashBytes.
any other way to convert to string? or this a bug? please help. thanks
Results:
The text was updated successfully, but these errors were encountered: