Is there a possibility to get the bytes representation of an integer? I want to use the bytes for the function native2unicode(bytes, 'UTF-8') to finisch the last few steps of the blowfish algorithm. Is there a proper way to do so? With dec2bin() I have not come far.

 採用された回答

James Tursa
James Tursa 2021 年 12 月 6 日
編集済み: James Tursa 2021 年 12 月 6 日

1 投票

Depending on what you are doing downstream with this, you can use the typecast( ) function. E.g.,
bytes = typecast(my_integer,'uint8');
Note that MATLAB uses two's complement bit representation for integers, so both signed and unsigned integers will simply be re-interpreted as a series of unsigned bytes in the above.

1 件のコメント

VectraY
VectraY 2021 年 12 月 6 日
thank you for your answer!

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

その他の回答 (0 件)

カテゴリ

製品

リリース

R2020b

質問済み:

2021 年 12 月 6 日

コメント済み:

2021 年 12 月 6 日

Community Treasure Hunt

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

Start Hunting!

Translated by