share
Stack OverflowAndroid Spongy Castle Gradle dependencies
[+2] [1] georgeok
[2016-02-18 15:58:14]
[ android gradle spongycastle ]
[ https://stackoverflow.com/questions/35486292/android-spongy-castle-gradle-dependencies ]

I am new to cryptography. I want to use Spongy Castle to encrypt (AES) to a file and write it to the disk. Do I need all the four(4) dependencies in my .gradle file?

compile 'com.madgag.spongycastle:core:1.51.0.0'
compile 'com.madgag.spongycastle:prov:1.51.0.0'
compile 'com.madgag.spongycastle:pkix:1.51.0.0'
compile 'com.madgag.spongycastle:pg:1.51.0.0'
[+12] [2016-02-18 16:27:11] Enrico [ACCEPTED]

Both pg and pkix depend on prov which depends core, so this should be sufficient to add all four jars to your project.

compile 'com.madgag.spongycastle:bcpkix-jdk15on:<version>'
compile 'com.madgag.spongycastle:bcpg-jdk15on:<version>'

But do you need both pkix and pg? One contains the APIs for PKIX, CMS, EAC, TSP, PKCS, OCSP, CMP, and CRMF and the other contains the OpenPGP APIs. You should only include the one you actually need.

Finally, unless you have a VERY GOOD REASON you should use the latest version of SpongyCastle - not just the version you copy-pasted from another StackOverflow answer. You can find the latest version [1] on Maven Central

[1] http://search.maven.org/#search%7Cga%7C1%7Cg:com.madgag.spongycastle

(1) The names have changed. You will need to use bcpkix-jdk15on instead of pkix and bcpg-jdk15on instead of pg, i.e. compile 'com.madgag.spongycastle:bcpkix-jdk15on:<version>' resp. compile 'com.madgag.spongycastle:bcpg-jdk15on:<version>' - winne2
Adding bcpkix-jdk15on is enough as it depeneds on prov and core? So there is no need of adding prov and core dependency explicitly? - Kalai.G
(1) No, they should already be dependencies of bcpkix or bcpg and will be included in your project automatically by maven or gradle - Enrico
1