如何使用 Qt/C++ 加密和解密文件?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1262081/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-27 19:22:04  来源:igfitidea点击:

How to encrypt and decrypt a file with Qt/C++?

c++qtencryptionqt4

提问by Berschi

I want to create a program, which can encrypt and decrypt a complete file with an individual password. Is there any way to manage this in Qt and/or C++ and how?

我想创建一个程序,它可以使用单独的密码加密和解密一个完整的文件。有什么方法可以在 Qt 和/或 C++ 中管理它,以及如何管理?

回答by Parker Coates

I've never used it myself, but I've heard great things about QCA. It's cross platfrom, uses a Qt-style API and Qt datatypes.

我自己从未使用过它,但我听说过关于QCA 的好消息。它是跨平台的,使用 Qt 风格的 API 和 Qt 数据类型。

回答by Kristoffon

www.cryptopp.com is a very complete C++ library with implementations of most algorithms.

www.cryptopp.com 是一个非常完整的 C++ 库,具有大多数算法的实现。

The actual program (select file, read, obtain key, encrypt etc) should be piece of cake.

实际的程序(选择文件、读取、获取密钥、加密等)应该是小菜一碟。

回答by Jake Petroules

Old, I know, but try Botan. It's actually used internally by Qt Creator 2.0. If you download the Qt Creator 2.0 sources you can find a copy of Botan 1.8.8 all set up for the Qt build system (qmake).

旧的,我知道,但试试Botan。它实际上是由 Qt Creator 2.0 内部使用的。如果您下载 Qt Creator 2.0 源代码,您可以找到为 Qt 构建系统 (qmake) 设置的 Botan 1.8.8 副本。

回答by John Calsbeek

Neither Qt nor the C++ standard library have encryption built-in. You'll need another external library to handle encryption.

Qt 和 C++ 标准库都没有内置加密。您将需要另一个外部库来处理加密。

回答by Manjeet Dahiya

Qt doesn't provide functionality to encrypt/decrypt.

Qt 不提供加密/解密功能。

QCryptographicHash only generates hashes. It is not what you are looking for.

QCryptographicHash 只生成散列。这不是你要找的。