hash.ts 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /**
  2. * Config source: https://git.io/JfefW
  3. *
  4. * Feel free to let us know via PR, if you find something broken in this config
  5. * file.
  6. */
  7. import Env from '@ioc:Adonis/Core/Env'
  8. import { hashConfig } from '@adonisjs/core/build/config'
  9. /*
  10. |--------------------------------------------------------------------------
  11. | Hash Config
  12. |--------------------------------------------------------------------------
  13. |
  14. | The `HashConfig` relies on the `HashList` interface which is
  15. | defined inside `contracts` directory.
  16. |
  17. */
  18. export default hashConfig({
  19. /*
  20. |--------------------------------------------------------------------------
  21. | Default hasher
  22. |--------------------------------------------------------------------------
  23. |
  24. | By default we make use of the argon hasher to hash values. However, feel
  25. | free to change the default value
  26. |
  27. */
  28. default: Env.get('HASH_DRIVER', 'scrypt'),
  29. list: {
  30. /*
  31. |--------------------------------------------------------------------------
  32. | scrypt
  33. |--------------------------------------------------------------------------
  34. |
  35. | Scrypt mapping uses the Node.js inbuilt crypto module for creating
  36. | hashes.
  37. |
  38. | We are using the default configuration recommended within the Node.js
  39. | documentation.
  40. | https://nodejs.org/api/crypto.html#cryptoscryptpassword-salt-keylen-options-callback
  41. |
  42. */
  43. scrypt: {
  44. driver: 'scrypt',
  45. cost: 16384,
  46. blockSize: 8,
  47. parallelization: 1,
  48. saltSize: 16,
  49. keyLength: 64,
  50. maxMemory: 32 * 1024 * 1024
  51. },
  52. /*
  53. |--------------------------------------------------------------------------
  54. | Argon
  55. |--------------------------------------------------------------------------
  56. |
  57. | Argon mapping uses the `argon2` driver to hash values.
  58. |
  59. | Make sure you install the underlying dependency for this driver to work.
  60. | https://www.npmjs.com/package/phc-argon2.
  61. |
  62. | npm install phc-argon2
  63. |
  64. */
  65. argon: {
  66. driver: 'argon2',
  67. variant: 'id',
  68. iterations: 3,
  69. memory: 4096,
  70. parallelism: 1,
  71. saltSize: 16
  72. },
  73. /*
  74. |--------------------------------------------------------------------------
  75. | Bcrypt
  76. |--------------------------------------------------------------------------
  77. |
  78. | Bcrypt mapping uses the `bcrypt` driver to hash values.
  79. |
  80. | Make sure you install the underlying dependency for this driver to work.
  81. | https://www.npmjs.com/package/phc-bcrypt.
  82. |
  83. | npm install phc-bcrypt
  84. |
  85. */
  86. bcrypt: {
  87. driver: 'bcrypt',
  88. rounds: 10
  89. }
  90. }
  91. })