Hi
code in Python
input = "Input1337"
encode = input.encode("utf-8")
hex = encode.hex()
oct = oct(int(hex, 16))
binary = " ".join(f"{ord(i):08b}" for i in input)
print("input :", input)
print("octal :", oct)
print("binary :", binary)
out:
input : Input1337
octal : 0o222671603527206114631467
binary : 01001001 01101110 01110000 01110101 01110100 00110001 00110011 00110011 00110111
in elixir:
input = "Input1337"
hex = Base.encode16(input)
IO.puts("Input : #{input}")
IO.inspect(hex, base: :binary)
IO.inspect(hex, base: :octal)
out:
Input : Input1337
<<0b1001001, 0b1101110, 0b1110000, 0b1110101, 0b1110100, 0b110001, 0b110011,
0b110011, 0b110111>>
<<0o111, 0o156, 0o160, 0o165, 0o164, 0o61, 0o63, 0o63, 0o67>>
I was only able to convert using IO.inspect
But I feel that I have made a mistake again
How can I save it in a variable like the Python code above?
Thanks