ideawu / Objective-C-RSA

Doing RSA encryption and decryption with Objective-C on iOS
http://www.ideawu.com/blog/post/132.html
Other
1.15k stars 280 forks source link

Equivalent openssl command #4

Closed harin closed 9 years ago

harin commented 9 years ago

Sorry for my ignorance, but what is the equivalent openssl command for to encrypt a string using this your code?

I have tried openssl rsautl -in test.txt -out output.txt -encrypt -pubin -inkey public.pem

but gets different result from encrypting the same text using this library.

I am trying to verify that what I have encrypted in iOS will be able to decrypt using another library.

Thanks

ideawu commented 9 years ago

Hi, I only provided PHP example(http://www.ideawu.com/blog/post/132.html ), you have to google for openssl command line example yourself.

ideawu commented 9 years ago

There are some useful links in that post.

harin commented 9 years ago

So I got it working. In case anyone wants to know the openssl command to decrypt. What I missed was I had to convert the string to binary first then decrypt.

base64 -D -i -ios_output.txt -o ios_bin.txt
openssl rsautl -in -ios_bin.txt -out ios_decrypt.txt -decrypt -inkey private.pem

At first I tried using the base64 command of openssl but it didn't work.