用go实现cfb1算法
```go
package cfb1
// CFB1 implements the Cipher Feedback Mode 1 algorithm as defined in NIST SP 800-38A.
// It takes a block cipher and uses it to encrypt a stream of data.
type CFB1 struct {
b BlockCipher // The underlying block cipher used for encryption/decryption.
block []byte // The current encrypted block. Used as an intermediate state between calls to Encrypt/Decrypt.
out []byte // The output buffer containing the encrypted/decrypted data.
outUsed int // How many bytes of out have been used so far?
// iv is the initialization vector for a new stream of data being encrypted/decrypted. It must be at least as long as b's block size (b.BlockSize()).
iv []byte
// feedback is how many bits from each block are fed back into the next encryption operation (and thus how much output is produced per call). Must be between 1 and b's block size (inclusive). If 0, defaults to b's block size (the full block).
feedback int
// firstBlock indicates if this is the first call to Encrypt or Decrypt with this instance of CFB1, in which case special handling must be done on the initial IV before continuing with normal operation.
firstBlock bool
}
免责声明:
以上内容除特别注明外均来源于网友提问,创作工场回答,未经许可,严谨转载。