1
0

randomBytes.spec.js 740 B

1234567891011121314151617181920212223242526
  1. /* Import modules. */
  2. const Nito = require('../..')
  3. describe('Crypto:randomBytes', () => {
  4. test('it should check the length of random bytes', async () => {
  5. /* Initialize byte size. */
  6. const byteSize = 32
  7. /* Generate random bytes. */
  8. const bytes = Nito.Crypto.randomBytes(byteSize)
  9. /* Evaluate test. */
  10. expect(bytes).toHaveLength(32)
  11. })
  12. test('it should check the length of random (hex) bytes', async () => {
  13. /* Initialize byte size. */
  14. const byteSize = 32
  15. /* Generate random (hex) bytes. */
  16. const bytes = Nito.Crypto.randomBytes(byteSize).toString('hex')
  17. /* Evaluate test. */
  18. expect(bytes).toHaveLength(byteSize * 2)
  19. })
  20. })