<commit_before>[[crypto-dataformat]]
= Crypto (Java Cryptographic Extension) DataFormat
:docTitle: Crypto (Java Cryptographic Extension)
:artifactId: camel-crypto
:description: Encrypt and decrypt messages using Java Cryptography Extension (JCE).
:since: 2.3
:supportLevel: Stable

*Since Camel {since}*

The Crypto Data Format integrates the Java
Cryptographic Extension into Camel, allowing simple and flexible
encryption and decryption of messages using Camel's familiar marshall
and unmarshal formatting mechanism. It assumes marshalling to mean
encryption to cyphertext and unmarshalling to mean decryption back to
the original plaintext. This data format implements only symmetric
(shared-key) encryption and decyption.

== CryptoDataFormat Options

// dataformat options: START
The Crypto (Java Cryptographic Extension) dataformat supports 10 options, which are listed below.



[width="100%",cols="2s,1m,1m,6",options="header"]
|===
| Name | Default | Java Type | Description
| algorithm |  | String | The JCE algorithm name indicating the cryptographic algorithm that will be used.
| cryptoProvider |  | String | The name of the JCE Security Provider that should be used.
| keyRef |  | String | Refers to the secret key to lookup from the register to use.
| initVectorRef |  | String | Refers to a byte array containing the Initialization Vector that will be used to initialize the Cipher.
| algorithmParameterRef |  | String | A JCE AlgorithmParameterSpec used to initialize the Cipher. Will lookup the type using the given name as a java.security.spec.AlgorithmParameterSpec type.
| buffersize |  | Integer | The size of the buffer used in the signature process.
| macAlgorithm | HmacSHA1 | String | The JCE algorithm name indicating the Message Authentication algorithm.
| shouldAppendHMAC | true | Boolean | Flag indicating that a Message Authentication Code should be calculated and appended to the encrypted data.
| inline | false | Boolean | Flag indicating that the configured IV should be inlined into the encrypted data stream. Is by default false.
| contentTypeHeader | false | Boolean | Whether the data format should set the Content-Type header with the type from the data format if the data format is capable of doing so. For example application/xml for data formats marshalling to XML, or application/json for data formats marshalling to JSON etc.
|===
// dataformat options: END
ND


== Basic Usage

At its most basic all that is required to encrypt/decrypt an exchange is a shared secret key.
If one or more instances of the Crypto data format are configured with this key the format can
be used to encrypt the payload in one route (or part of one) and decrypted in another.
For example, using the Java DSL as follows:
<commit_msg>Removed useless statement from crypto docs<commit_after>[[crypto-dataformat]]
= Crypto (Java Cryptographic Extension) DataFormat
:docTitle: Crypto (Java Cryptographic Extension)
:artifactId: camel-crypto
:description: Encrypt and decrypt messages using Java Cryptography Extension (JCE).
:since: 2.3
:supportLevel: Stable

*Since Camel {since}*

The Crypto Data Format integrates the Java
Cryptographic Extension into Camel, allowing simple and flexible
encryption and decryption of messages using Camel's familiar marshall
and unmarshal formatting mechanism. It assumes marshalling to mean
encryption to cyphertext and unmarshalling to mean decryption back to
the original plaintext. This data format implements only symmetric
(shared-key) encryption and decyption.

== CryptoDataFormat Options

// dataformat options: START
The Crypto (Java Cryptographic Extension) dataformat supports 10 options, which are listed below.



[width="100%",cols="2s,1m,1m,6",options="header"]
|===
| Name | Default | Java Type | Description
| algorithm |  | String | The JCE algorithm name indicating the cryptographic algorithm that will be used.
| cryptoProvider |  | String | The name of the JCE Security Provider that should be used.
| keyRef |  | String | Refers to the secret key to lookup from the register to use.
| initVectorRef |  | String | Refers to a byte array containing the Initialization Vector that will be used to initialize the Cipher.
| algorithmParameterRef |  | String | A JCE AlgorithmParameterSpec used to initialize the Cipher. Will lookup the type using the given name as a java.security.spec.AlgorithmParameterSpec type.
| buffersize |  | Integer | The size of the buffer used in the signature process.
| macAlgorithm | HmacSHA1 | String | The JCE algorithm name indicating the Message Authentication algorithm.
| shouldAppendHMAC | true | Boolean | Flag indicating that a Message Authentication Code should be calculated and appended to the encrypted data.
| inline | false | Boolean | Flag indicating that the configured IV should be inlined into the encrypted data stream. Is by default false.
| contentTypeHeader | false | Boolean | Whether the data format should set the Content-Type header with the type from the data format if the data format is capable of doing so. For example application/xml for data formats marshalling to XML, or application/json for data formats marshalling to JSON etc.
|===
// dataformat options: END


== Basic Usage

At its most basic all that is required to encrypt/decrypt an exchange is a shared secret key.
If one or more instances of the Crypto data format are configured with this key the format can
be used to encrypt the payload in one route (or part of one) and decrypted in another.
For example, using the Java DSL as follows:

{'fraction_non_alphanumeric': 0.05415162454873646, 'fraction_numerical': 0.004332129963898917, 'mean_word_length': 4.863492063492063, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '826359', 'n_tokens_mistral': 1392, 'n_tokens_neox': 1320, 'n_words': 740}