1

Tarantool must return a string of 256 bits for example: 40ee6e5a8195284884215c2fcd476a4e4ad9a65adde8eea3efcc15b93fb44d65

Andrew Nodermann
  • 610
  • 8
  • 13

1 Answers1

3

Built-in module digest can be used for this task. See an example:

tarantool> dg = require'digest'
---
...
tarantool> string.hex(dg.urandom(32))
---
- 3eeed423dd94abddbdeb0a27fea8f4926d77b75bb22f90b8cbb11530323c6d23
...

Of course, it's better to pass some unique meaningful information related to the session or a unique identifier -- uuid module or digest.urandom can be used for this. Be sure that the generated hash is unique enough and cannot be brute-forced within the session lifetime -- see, for example, this answer for an explanation.

The digest module also contains several variants of SHA lengths and their counterparts returning hex strings:

tarantool> dg.sha224_hex(dg.urandom(256))
---
- 6a8aa191d30f068a97c31a8c826d1b3e74d9890d57b8cbb7e2c65ca1
...
akudiyar
  • 370
  • 2
  • 9