I am trying to create a app with users and logins

@simonzhang just tested out some things, and it turns out you can use import in Server actions. So technically, you could do something like this

So you could use bcrypt in Server actions if you’d like to. But as you can see, you need to provide an CSPRNG (cryptographic pseudorandom number generator) because neither Web Crypto API nor Node.js crypto are available.

Here is the code of the image above so you can see for yourself : )

import bcrypt from 'https://cdn.jsdelivr.net/npm/bcryptjs@3.0.2/+esm';
import isaac from 'https://cdn.jsdelivr.net/npm/isaac@0.0.5/+esm';

bcrypt.setRandomFallback((len) => {
	const buf = new Uint8Array(len);

	return buf.map(() => Math.floor(isaac.random() * 256));
});

return bcrypt.hashSync("myPassword", 10)
1 Like