I wanted to encrypt a large binary file using crypto++ library with asymmetric encryption(RSA) algorithm. I have searched for working example and couldn't find it.
Is it possible? What kind of things should i consider when i implement it using this library
Related
I'm trying to encrypt and decrypt PDF file using crypto and everything works well but I need to use another library like Cryptography https://github.com/pyca/cryptography .
How I can use Cryptography library to encrypt and decrypt files like PDF file because I search a lot and I can't find one example of how I can use Cryptography with files.
Any example may help.
To answer your question Cryptography's documentation could potentially help you with this. I used the library to encrypt text files, python files, i not sure about pdf's though. But the doc's were helpful. https://cryptography.io/en/latest/
Plus this website also helped me out as well.
https://www.thepythoncode.com/article/encrypt-decrypt-files-symmetric-python
It implements the Fernet key type encryption which is symmetric encryption.
There is asymmetric encryption (I believe this type uses public and private keys) you can as far i know encrypt strings with this type of encryption. As far as encrypting files with this type of encryption i am not sure about that as i have not done any research on that my self lol!
I was messing around with some of the functions in this library and found some useful things in it. Hope this helps.
p.s. Stay away from the hazmat section of this library. ONLY use this if you really know what your doing in terms of cryptography!
So I was looking at ways to lock file folders with a password in windows, and this type of security is not really supported.
Given I know C++ I was wondering if I could simply do this myself.
It would be simple enough, in the case of a text file, to copy the entire contents of the file into a C-string. I could then use basic logic to prompt for a password, if it matches, use an fstream overload and insert the whole string into a text file.
Then, simply wipe the file when I'm done using it.
I basically know how to do this, and the result would be a string containing the document compiled into a .exe which I assume would be unreadable. The thing is, I've never really studied encryption or computer security so I'm wondering how secure this would be, or if there is a better way to do this?
Could it be done on photo or video files as well, if so, how?
How hard would it be to reverse (decompile) the process?
What types of things could I do to make reversal more difficult, ie. using multiple strings, or mixing in random characters?
I'm not looking to hide super-sensitive files, I'm just curious about encryption basics.
Never implement crypto yourself - it is destined to fail. Use well reviewed libraries such as OpenSSL. A good example of using AES for file encryption: Encrypting and decrypting a small file using openssl
Using such simple approach will let you encrypt any file. And it will be secure. Why settle for weak encryption if you can have strong encryption?
If you don't want to write a program, just get, for example, OpenSSL and use the terminal: openssl des3 -salt -in file.txt -out file.des3
I'm porting a portion of a .NET application to Qt on Linux. I am trying to replicate the results of a .NET function to create the SHA-256 hash of a password + salt. The .NET code is
return new SHA256Managed().ComputeHash(buffer);
Where buffer is the salt concatenated to the password.
I considered several crytopgraphic libraries including QCA and Botan and after reading several comments, I decided to try Botan. However, I'm not finding the right place in the documentation to perform the equivalent of the code listed above.
Can someone point me to the place in the fine manual or a tutorial that discusses the use of Botan to create a simple hash? I've been google searching for a couple hours without finding a solution. There are many example of SHA-256 hashing for pipes and streams but I have yet to find the example of a simple hash calculation.
I'm guessing you just need the documentation.
The code to do what you want is something like:
#include <vector>
#include <sha2_32.h>
using namespace Botan;
secure_vector<byte> somefunction(std::vector<byte> input) {
SHA_256 sha;
return sha.process(input);
}
As I mentioned in my comment, this is an incredibly insecure way to store passwords, so I'd recommend using bcrypt or PBKDF2 (both of which are implemented in Botan). PBKDF2 is part of the .NET standard library too, so there's really no excuse to use a general-purpose hash function instead of a secure password hashing function.
All you need for bcrypt is:
generate_bcrypt(password, random_number_generator, work_factor)
I would like to create an IV encryption with aes 256 and cbc pkcs7 padding. I would like to ask if there is a library in linux that implements this type of encryption. I don't want to add dependency files/ libraries. THX! APPRECIATE
If there is nothing like this includes in Linux(I am working on Ubuntu) could you please specify a simple and easy way to do this encryption in c++ (add it's files and headers in my code). THX. APPRECIATE!!
You can use Crypto++
http://www.cryptopp.com/
I use it for the RSA and find it satisfactory.
See http://www.openssl.org/docs/crypto/crypto.html
Subj. I need to sign/verify under Windows in native C++ (no .NET), using private key for signing, public key for verification.
I saw few examples on MSDN (http://msdn.microsoft.com/en-us/library/ms761363(VS.85).aspx) that demonstrate how to sign the document with CSP (I don't know what this means).
For my case I need to use a "key" from the binary data array (using DSA encryption algorithm)... can somebody help me with that?
Thank you in advance.
I recommand libxml2 and xmlsec which are perfect for this purpose.
The API can seem hard to read at first, but it works well. xmlsec uses OpenSSL to achieve the cryptographic part.
Providing a "short" example here is probably hard because the three libraries require some initialization and a lot of C calls.
Google's keyczar lib is also very easy to use
There's also Crypto++