Hashing Data in MATLAB

조회 수: 139 (최근 30일)
Z
Z 2023년 7월 6일
댓글: Z 2023년 7월 13일
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
Walter Roberson
Walter Roberson 2023년 7월 13일
@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 2023년 7월 13일
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.

댓글을 달려면 로그인하십시오.

채택된 답변

Pratyush
Pratyush 2023년 7월 7일
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
Pratyush
Pratyush 2023년 7월 7일
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 2023년 7월 7일
Will try it, thank you !

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Simulink Coder에 대해 자세히 알아보기

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by