What is the standard Java crypto API?

I want to implement a tool in Java to learn more about cryptography. I know that there is a security package with some cryptographic materials inside. Now I saw that there is a special javax.crypto package in the SDK.

Where is the difference? Are they both relevant?

I wanted to run my tool with some historical ciphers. But this should not be limited to them. So I need a good abstraction via interfaces or something like that.

What is the best choice for two APIs? Is there any other API I should take a look at?

Thanks in advance.

+7
java api cryptography
source share
7 answers

To answer the question:

javax.crypto uses low-level cryptography: encryption, decryption, and hashing. This is where the Cipher class is defined.

java.security deals with everything else: SecureRandom, key management, certificate management and signatures.

These interfaces describe JCE providers that implement specific algorithms. JRE provides some of the boxes, and BouncyCastle is another good one.

If you plan some custom ciphers for which there is no implementation yet, you will implement your own JCE provider and, in particular, extend javax.crypto.CipherSpi .

It is not difficult, but you should read the documentation on how to do this . In order for JCE to allow your provider, you will need to contact Oracle for a certificate, basically faxing a signed expression stating that you know US export restrictions on cryptographic libraries.

+11
source share

This is a combination of two packages.

Here are the relevant documents

+2
source share

You can take a look at the Legion of Wan Castle

+2
source share
+2
source share

http://www.jasypt.org is also a good option.

+2
source share

Extensions of Java Cryptography (Practical Guide Series) by Jason Weiss.

I spent a lot on books, I have a lot of books, they are all very good. (if you have masters in mathematics)

This book has come to the point, I had a cipher working after 5-6 hours. I worked 5-6 years to run. A lot of practical advice from a decade of working with factual information.

+2
source share

You can use Apache Commons Crypto.

Apache Commons Crypto is a cryptographic library optimized using AES-NI (Advanced Encryption Standard New Instructions). It provides a Java API for the encryption level and Java stream level. Developers can use it to implement high-performance AES encryption / decryption with minimal code and effort. Please note that Apache Commons Crypto does not implement a cryptographic algorithm such as AES directly. It portes to Openssl or JCE, which implement the algorithms.

Please see here: - https://commons.apache.org/proper/commons-crypto/

+1
source share

All Articles