JuliaCrypto / Nettle.jl

Julia wrapper around nettle cryptographic hashing/encryption library providing MD5, SHA1, SHA2 hashing and HMAC functionality, as well as AES encryption/decryption

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

You had better use 'sizeof()' instead of 'length()' .

HatsuneMiku opened this issue · comments

I think you had better use 'sizeof()' instead of 'length()' .

fails by c assertion

willcauseassertion = "this is 16 (∀).."
length(willcauseassertion) # 16
sizeof(willcauseassertion) # 18
willcauseassertion.data == decrypt(dec, encrypt(enc, willcauseassertion))

or unexpected through the length check

willbebroken = "this is 16 (∀)"
length(willbebroken) # 14
sizeof(willbebroken) # 16
willbebroken.data == decrypt(dec, encrypt(enc, willbebroken)) # must be true, but broken result = Array(Uint8, length(data))

Fix it, and open the pull request.
https://github.com/HatsuneMiku/Nettle.jl/tree/_dev_aes256cbc

I believe this has been addressed by #64.

As a side note, the English expression "You had better...." has a stronger meaning than I believe you intend. It's generally reserved for when someone must do something (closer to しなくてはいけません than したほうがいい). In this case, alternative phrases could be It's better to use 'sizeof()' instead of 'length()', or even just 'Use 'sizeof()' instead of 'length()'`. Strange that it sounds less aggressive to omit any kind of phrase before the verb 'use', but English is strange sometimes. ;)

Thank you for your contributions, and I hope to see more good work from you in the future! :)