Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在实现一个原始分组密码。但是,实现方式是密文的大小可能与明文的大小不同。我需要知道如何计算编码后形成的密文的大小。strlen(char *) 将不起作用,因为密文可能包含多个 '\n' 字符。有没有解决这个问题的方法?
您的编码函数应该返回大小,它是唯一知道它的实体。实现一个单独的函数来“找出大小”意味着重新实现算法的一半。
所以如果在你的编码函数中你有这样的东西:
while (...) buf[i++] = stuff;
你应该返回i。
i