xiaoing.com©

开花即结果 提问即答案

用go实现cfb1算法
原始问题:

用go实现cfb1算法

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  
用go实现cfb1算法
https://www.xiaoing.com/zhidao/11299.html
AI / 模型DeepSeek
时间 / DATEApril 16, 2023, 2:16 PM
语言zh-CN
IP / 区域四川 成都