How can I apply hash on a string.

6 ビュー (過去 30 日間)
Balkar Singh
Balkar Singh 2020 年 4 月 18 日
コメント済み: Balkar Singh 2020 年 4 月 20 日
How can i apply hash function on a string and reverse process to generate the same string from the hash value.

採用された回答

Ameer Hamza
Ameer Hamza 2020 年 4 月 18 日
Hashing is not a reversible process. You can do encoding and decoding. For example
A = 'The quick brown fox jumps over the lazy dog';
encoded_str = matlab.net.base64encode(A);
decoded_str = char(matlab.net.base64decode(encoded_str));
Result
>> encoded_str
encoded_str =
'VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw=='
>> decoded_str
decoded_str =
'The quick brown fox jumps over the lazy dog'
  10 件のコメント
Ameer Hamza
Ameer Hamza 2020 年 4 月 20 日
Balkar, mlreportgen.utils.hash returns a string, which is different from char array in MATLAB. length(encoded_str) returns 1 always. Change it to char array by changing the line
encoded_str=mlreportgen.utils.hash(cover_str);
to
encoded_str=char(mlreportgen.utils.hash(cover_str));
Balkar Singh
Balkar Singh 2020 年 4 月 20 日
OK sir..Thank you very much

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangePerformance and Memory についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by