Hashing Data in MATLAB
조회 수: 139 (최근 30일)
이전 댓글 표시
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
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".
채택된 답변
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))
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
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.
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!