Hashing Data in MATLAB

138 visualizaciones (últimos 30 días)
Z
Z el 6 de Jul. de 2023
Comentada: Z el 13 de Jul. de 2023
Hello everyone,
I wanted to know if there is a possibility to hash any type of data through simulink without the need to use the Cryptography Toolbox in MATLAB.
I have attempted to use the MATLAB Function block in Simulink which seemed like a promising approach. However, I encountered a compatibility error
I am reaching out to this forum to seek guidance and suggestions on how I can successfully hash data in Simulink using other alternative approaches or workarounds, I would greatly appreciate your input.
Thank you in advance for your assistance.
  6 comentarios
Walter Roberson
Walter Roberson el 13 de Jul. de 2023
@Z flagged (their own) question with the words
Hashing laws in US
Z:
The USA has no laws preventing the discussion of hashing algorithms, or of posting hashing code. US laws specifically permit the use of hashing for authentication, for example.
The USA does have laws that restrict the discussion of encryption algorithms. The distinction between hashing and cryptography is not always clear, but generally speaking, it is cryptography when there is an intention to recover information. When the purpose of an algorithm is to validate that the contents of a message have not been altered, or to provide mapping from longer original data to slots ("hashing"), or to authenticate that the message is from the claimed sender, then none of those functions are (typically) considered encryption.
Is it possible to use "hashing" / "message digest" functions that are not controlled by US law, and end up with "encryption" functionality? Sort of; it is not "supposed to be" possible, but I read a concept paper in which someone proved that in theory you can use authentication processes to effectively carry information (encryption); the particular approach they outlined involved re-sending the data multiple times, so that particular approach was not "efficient", but it did demonstrate that you cannot create a clear boundary between hashing and "encryption".
Z
Z el 13 de Jul. de 2023
Oh i see your point.
Because my last post got flagged too for this reason:
@Walter Roberson : "Not appropriate for MATLAB Answers - sorry due to the laws of the United States of America, we cannot discuss encryption algorithms here".
But i see the distinction now from your comment.
Thank you.

Iniciar sesión para comentar.

Respuesta aceptada

Pratyush
Pratyush el 7 de Jul. de 2023
Hi ally. It is my understanding that you want to acheive hashing in MATLAB function block of Simulink without using the Cryptography toolbox. Here is how you can achieve it using the MD5 (message-digest algorithm).
import java.security.*;
import java.math.*;
md = MessageDigest.getInstance('MD5');
hash = md.digest(double('myPassword'));
bi = BigInteger(1, hash);
char(bi.toString(16))
ans = 'deb1536f480475f7d593219aa1afd74c'
The above example uses MD5, a one-way cryptography function that accpets a message of any length and returns a fixed length digest value. You may refer the resources below to know more about the MD5 hashing algorithm and the method shown above.
  3 comentarios
Pratyush
Pratyush el 7 de Jul. de 2023
Can you try with MATLAB system block in Simulink. It can take a string as an input, internally perform the hashing and return the hashed string as the output. Since the MATLAB system block uses matlab script for execution, it might work.
Here is the documentation for MATLAB System block.
Z
Z el 7 de Jul. de 2023
Will try it, thank you !

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Simulink Coder en Help Center y File Exchange.

Productos


Versión

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by