https://discord.cloudflare.com logo
Join Discord
Powered by
# functions
  • i

    i40west

    11/20/2022, 6:11 PM
    There's a pure-Javascript bcrypt module called bcryptjs, but since it's pure JS it will need more CPU than you get on the free plan
  • i

    i40west

    11/20/2022, 6:11 PM
    Then there's stuff that's supported here: https://developers.cloudflare.com/workers/runtime-apis/web-crypto/
  • s

    Skye

    11/20/2022, 6:12 PM
    Looks like https://github.com/cloudflare/next-on-pages/issues/1 will need to be resolved first
  • s

    salutalice

    11/20/2022, 6:14 PM
    Is it supported on paid plans ?
  • i

    i40west

    11/20/2022, 6:15 PM
    I haven't used it personally but others have, yes. I understand it takes a few hundred milliseconds
  • i

    i40west

    11/20/2022, 6:16 PM
    If you try it on a free plan it should run and you can see how it works
  • i

    i40west

    11/20/2022, 6:16 PM
    you don't automatically get killed when you hit the cpu limit so for a few requests it should work
  • s

    salutalice

    11/20/2022, 6:19 PM
    Thanks I will take a look
  • z

    zsmooth

    11/20/2022, 6:42 PM
    Definitely use the crypto stuff that’s built in, not the js bcrypt 🙂
  • s

    salutalice

    11/20/2022, 6:46 PM
    built in is just sha512 right ?
  • s

    salutalice

    11/20/2022, 6:46 PM
    is this oke to use for user data ?
  • i

    i40west

    11/20/2022, 6:50 PM
    I don't see why not, and it would be easier and faster and one less dependency
  • z

    zsmooth

    11/20/2022, 6:55 PM
    You get a bunch of SHAs and MD5. Depends on your use case, but SHA512 should work for most things
  • s

    salutalice

    11/20/2022, 7:14 PM
    oke thanks people
  • w

    Walshy | Pages

    11/20/2022, 7:36 PM
    I appreciate the fix 🙂 Please keep them coming!
  • w

    Walshy | Pages

    11/20/2022, 7:47 PM
    SHA is not good for passwords
  • w

    Walshy | Pages

    11/20/2022, 7:47 PM
    But for like integrity yes
  • s

    salutalice

    11/20/2022, 7:53 PM
    how should I store and hash passwords with workers then, if they can't use « standards » like bcrypt ?
  • z

    zsmooth

    11/20/2022, 8:03 PM
    Yeah i wasn’t thinking of passwords when i heard “hashing”. I’m don’t know if any of the web crypto algos CF gives you are appropriate…
  • z

    zsmooth

    11/20/2022, 8:05 PM
    Maybe this PBKDF2 (but see note at top and comments) https://gist.github.com/chrisveness/770ee96945ec12ac84f134bf538d89fb
  • z

    zsmooth

    11/20/2022, 8:09 PM
    Based on your use case you might want that js bcrypt after all… but you’ll probably need to use unbound
  • j

    James

    11/20/2022, 8:10 PM
    Yeah you can definitely use bcrypt or argon2 with Workers, but you'll need more CPU time via unbound
  • s

    salutalice

    11/20/2022, 8:11 PM
    can I somehow calculate the costs beforehand ?
  • j

    James

    11/20/2022, 8:12 PM
    https://pricing.ceru.dev/ will be your best bet
  • j

    James

    11/20/2022, 8:12 PM
    You get a healthy amount for free in the base paid plan - more than enough to test and get an idea for how long it'll take, and you can then estimate costs
  • s

    salutalice

    11/20/2022, 8:17 PM
    I'm so confused of 'how long does the worker run'
  • s

    salutalice

    11/20/2022, 8:17 PM
    where can I test this ?
  • s

    salutalice

    11/20/2022, 8:17 PM
    I will be way way way below 100 000 requests per months
  • s

    salutalice

    11/20/2022, 8:17 PM
    I may be even not hitting 1000
  • j

    James

    11/20/2022, 8:19 PM
    I believe wrangler will tell you the response time for a request, which should give you some idea. You can also check the worker stats in the dash too
1...307308309...392Latest