Is it possible to encrypt a .p7b file using a passphrase. ? I need to support the encrypted PKCS#7 files and then later use the java code to decrypt it.
Asked
Active
Viewed 262 times
0
-
Every file can be encrypted and decrypted as byte arrays! – Majid Hajibaba Jul 13 '21 at 10:05
-
1Does this answer your question? [Using password-based encryption on a file in Java](https://stackoverflow.com/questions/13673556/using-password-based-encryption-on-a-file-in-java) – Majid Hajibaba Jul 13 '21 at 10:07
-
https://datatracker.ietf.org/doc/html/rfc3211 – President James K. Polk Jul 13 '21 at 11:45
1 Answers
0
Yes, you can do it in three steps:
- Derive a key from your passphrase
- Encrypt data with key
- Package data into PKCS7/CMS format
Step 1 - Key Derivation
There are a few options for this. Some of the more common options are PBKDF2, Argon2, and BCrypt.
Steps 2 & 3 - Encryption & CMS Packaging
Since you tagged this with Java, I recommend using Bouncy Castle's CMSEncryptedDataGenerator class to construct the CMS object.

Hmmmmm
- 778
- 9
- 20