Borrar filtros
Borrar filtros

How to generate 500 random string keys in matlab?

57 visualizaciones (últimos 30 días)
Benjamin Bax
Benjamin Bax el 4 de Jun. de 2020
Comentada: Rik el 9 de Jun. de 2020
I need to understand on how to generate 500 random strings in matlab. and to generate hash values for the same.

Respuestas (1)

Mohammad Sami
Mohammad Sami el 4 de Jun. de 2020
You can use the randi function to generate integers corresponding to the ascii values you want to allow in your random string.
An example to generate a character of length of 100 is as follows.
randomstr = char(randi([33 126],1,100));
  6 comentarios
Benjamin Bax
Benjamin Bax el 9 de Jun. de 2020
Hello thanks for the response, also how do we compute a hash function for string keys?
Rik
Rik el 9 de Jun. de 2020
You pick a function that computes a hash (e.g. the one Mohammad linked), and you provide your char array as the input. Although since you are generating a random string anyway, why don't you generate a random array of 0-9A-F as a stand-in for your hash?
What are you trying to achieve?

Iniciar sesión para comentar.

Categorías

Más información sobre Characters and Strings en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by