0

I have a public key (modulus and exponent) in Base64 encoded form: MIICIjANBgkqhkiG9w0B AQEFAAOCAg8AMIICCgKCAgEA4IJZLsjlx+o4RSvafaAcReoNnzrI0UXu7kZyXPe31ql32X9AvhC6QQIU...

I want to encrypt a text file in LInux using openssl. I have re-written the public key in text file And convert it to .pem file .(just changed the extension) and then execute these commands:

openssl rsautl -encrypt -pkcs -inkey Key.pem -pubin -in s2.txt -out rsa_4096.bin

openssl -encrypt -e -base64 -in rsa_4096.bin -out s2encrypted.txt 

The problem is that I cannot encrypt the file.

Does anyone have any one idea about this

4
  • 1
    What do you mean by "you cannot encrypt the file"? What happens when you attempt it? Is there some output from the mystical command that you've entered? – garethTheRed May 18 '16 at 14:30
  • Your question as currently written is not clear. You should provide specifics in order to clarify your question. – Ramhound May 18 '16 at 14:38
  • i did a modification – Marzo May 18 '16 at 15:33
  • @Marzo - You need to say more than "The problem is that I cannot encrypt the file". What is wrong? What is the error code you get from OpenSSL? What step did the error happen? Also, it appears you are encrypting twice. Is this the case, or are you trying to say that you tried both commands? – jww May 21 '16 at 1:55
0
openssl rsautl -encrypt -pkcs -inkey Key.pem -pubin -in s2.txt -out rsa_4096.bin

command to encrypt with public key seems fine to me. but as you wrote

I want to encrypt a text file in LInux using openssl. I have re-written the public key in text file And convert it to .pem file .(just changed the extension)

just change the extension can't make any file .PEM file.

PEM FILE - If they begin with -----BEGIN and you can read them in a text editor (they use base64, which is readable in ASCII, not binary format), they are in PEM format.

can check Here hope this links help. Also share the full log so that we could see what error you are getting during RSA Encrypt operation.

Hope it helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.