Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ruby – バイナリと16進数のHEXを相互変換する #3598

Open
YumaInaura opened this issue Apr 18, 2024 · 0 comments
Open

Ruby – バイナリと16進数のHEXを相互変換する #3598

YumaInaura opened this issue Apr 18, 2024 · 0 comments

Comments

@YumaInaura
Copy link
Owner

コード例

def bin_to_hex(str)
  str.each_byte.map { |b| b.to_s(16).rjust(2, '0') }.join
end

def hex_to_bin(hex)
  [hex].pack('H*')
end

bin_to_hex(binary_string)

hex_to_bin(hex_string)

チャットメンバー募集

何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

https://line.me/ti/g2/eEPltQ6Tzh3pYAZV8JXKZqc7PJ6L0rpm573dcQ

プロフィール・経歴

https://github.com/YumaInaura/YumaInaura

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant