Base64Decode:如何获取数据
这似乎是一个简单的问题,但 crypto++ 似乎是以一种时髦的、“尽可能迟钝”的方式设计的,所以我想知道......
我怎样才能从 CryptoPP:: 中获取二进制数据Base64Decode 对象?假设我不想将其写入文件或以其他方式对其进行编码,我如何获取实际的二进制数据?
编辑:弄清楚了;不知道如何关闭/删除它,有人吗?我现在在这里做什么合适?
This seems like it would be an easy question, but crypto++ seems to be designed in a funky, "as obtuse as possible" sorta way, so I'm wondering...
How can I get the binary data out of the CryptoPP::Base64Decode object? Assuming I don't want to write it to a file, or encode it some other way, how do I just get at the actual binary data?
Edit: figured it out; not sure how to close/delete it, anyone? What's the appropriate thing for me to do here now?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
没关系,想通了。作为参考,我想获取 BufferedTransformation 子类的 MaxRetrievable 和 Get 方法。
Nevermind, figured it out. For reference, I wanted to get the MaxRetrievable and Get methods of the BufferedTransformation subclass.
如果您不熟悉 Crypto++ 设计,这不是一个简单的问题。实际上有两种设计在起作用。
首先是经典的更新/最终。它在 Crypto++ 中通过
Put
和Get
等实现。二是管道设计。这就是数据从源流向接收器的地方,您将看到它,例如:
管道相当于 Unix 命令:
管道概括为:
在内部,源将在第一个过滤器上调用
Put
;第一个过滤器将转换数据并在第二个过滤器上调用Put
,依此类推。最后一个过滤器将在 Sink 上调用Put
。更准确地说,源和过滤器将调用Put2
,但这是一个实现细节。如果没有Sink:
那么Filter会在内部缓冲转换后的数据。您可以使用
Get
、GetWord16
、GetWord32
、MaxRetrievable
、AnyRetrievable
等来从过滤器或接收器中提取数据。Put
、Get
、MaxRetrievable
等都是BufferedTransformation
接口的一部分,这是一个所有过滤器和接收器实现(实际上不需要源来实现它)。如果一个类不提供Put
、Get
等功能,那么它就不是过滤器或接收器。该类的文档位于 BufferedTransformation 类参考。它还有很多功能,包括阻塞和泵送数据块,但 Base64 过滤器或对象并不真正需要它。上例中的pumpAll表示一次性推送所有数据。
Its not an easy question if you are not familiar with the Crypto++ design. There's actually two designs at work.
First is a classical Update/Final. Its implemented in Crypto++ with
Put
andGet
and friends.The second is a pipleline design. That's where data flows from source to sink, and you'll see it as, for example:
The pipeline is equivalent to Unix commands:
The pipeline generalizes to:
Internally, Source will call
Put
on the first filter; the first filter will transform the data and callPut
on the second filter, and so on. The last filter will callPut
on the Sink. More correctly, the Source and Filters will callPut2
, but that's an implementation detail.If there is no Sink:
then the Filter will internally buffer the transformed data. You can use
Get
,GetWord16
,GetWord32
,MaxRetrievable
,AnyRetrievable
, etc to extract data from the filter or sink.Put
,Get
,MaxRetrievable
and friends are part of theBufferedTransformation
interface, and that's an interface that all filters and sinks implement (there's really no need for a source to implement it). If a class does not providePut
,Get
and friends, then its not a filter or sink. Documentation for the class is located at BufferedTransformation Class Reference.There's a lot more to it, including blocking and pumping data in blocks, but its not really needed for a Base64 filter or object. The
pumpAll
in the above example means to push all data at once.