You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Well, I need it to implement a protocol (to encrypt the IV that's sended before the
actual content) and I don't know much about cryptography, so I'm a bit cautious to
implement it myself.
IV are supposed to be public and shouldn't be encrypted, but anyway...
ECB is essentially "no mode" and while it isn't supported in a named fashion,
crypto/cipher.Block.Encrypt and Decrypt implement it on a block by block basis. You just
need to feed in a multiple of the blocksize:
bs := block.BlockSize()
if len(plaintext) % bs != 0 {
panic("Need a multiple of the blocksize")
}
ciphertext := make([]byte, len(plaintext))
for len(plaintext) > 0 {
block.Encrypt(ciphertext, plaintext)
plaintext = plaintext[bs:]
ciphertext = ciphertext[bs:]
}
[1] http://golang.org/pkg/crypto/cipher/#Block
by hebipp1:
The text was updated successfully, but these errors were encountered: