Created
June 19, 2017 20:26
-
-
Save jerojasro/5596646cdf0802db9126497925ad07e3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# DOES NOT WORK | |
def sub_word(<< w :: size(32) >>) do | |
for <<b <- w>>, into: <<>> do | |
<< :binary.at(@s_box, b) >> | |
end | |
end | |
# ** (ArgumentError) argument error | |
# :erlang.bit_size(1) | |
# lib/symmetric/aes.ex:27: Symmetric.AES.sub_word/1 | |
# WORKS | |
def sub_word_alt(<< a, b, c, d >>) do | |
<< | |
:binary.at(@s_box, a), | |
:binary.at(@s_box, b), | |
:binary.at(@s_box, c), | |
:binary.at(@s_box, d), | |
>> | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment