<commit_before>Chimera is a project which strips code related to CryptoInputStream/CryptoOutputStream from Hadoop to facilitate AES-NI based data encryption in other projects.

## Features
  * Fast encryption/decryption
  * JNI-based implementation to achieve comparable performance to the native C++ version based on Openssl
  * Portable across various operating systems (currently only Linux); Chimera loads the library according to your machine environment (It looks system properties, `os.name` and `os.arch`). 
  * Simple usage. Add the chimera-(version).jar file to your classpath.
  * [Apache License Version 2.0](http://www.apache.org/licenses/LICENSE-2.0). Free for both commercial and non-commercial use.

## Download
  * Release version: http://central.maven.org/maven2/com/intel/chimera/chimera/
  * Snapshot version (the latest beta version): https://oss.sonatype.org/content/repositories/snapshots/com/intel/chimera/chimera/

### Using with Maven
  * Chimera is available from Maven's central repository:  <http://central.maven.org/maven2/com/intel/chimera/chimera>

Add the following dependency to your pom.xml:

    <dependency>
      <groupId>com.intel.chimera</groupId>
      <artifactId>chimera</artifactId>
      <version>0.0.1</version>
      <type>jar</type>
      <scope>compile</scope>
    </dependency>

### Using with sbt

```
libraryDependencies += "com.intel.chimera" % "chimera" % "0.0.1"
```

## Usage 

```java
CryptoCodec codec = CryptoCodec.getInstance();
byte[] key = new byte[16];
byte[] iv = new byte[16];
int bufferSize = 4096;
String input = "hello world!";
byte[] decryptedData = new byte[1024];
// Encrypt
ByteArrayOutputStream os = new ByteArrayOutputStream();
CryptoOutputStream cos = new CryptoOutputStream(os, codec, bufferSize, key, iv);
cos.write(input.getBytes("UTF-8"));
cos.flush();
cos.close();

// Decrypt
CryptoInputStream cis = new CryptoInputStream(new ByteArrayInputStream(os.toByteArray()), codec, bufferSize, key, iv);
int decryptedLen = cis.read(decryptedData, 0, 1024);
```

### Configuration
Currently, two crypto codec are supported: JceAesCtrCryptoCodec and OpensslAesCtrCryptoCodec, you can configure which codec to use as follows:

    $ java -Dchimera.crypto.codec.classes.aes.ctr.nopadding=com.intel.chimera.OpensslAesCtrCryptoCodec Sample
    $ java -Dchimera.crypto.codec.classes.aes.ctr.nopadding=com.intel.chimera.JceAesCtrCryptoCodec Sample
<commit_msg>Doc: update the readme since 0.5.0 released<commit_after>Chimera is a project which strips code related to CryptoInputStream/CryptoOutputStream from Hadoop to facilitate AES-NI based data encryption in other projects.

## Features
  * Fast encryption/decryption
  * JNI-based implementation to achieve comparable performance to the native C++ version based on Openssl
  * Portable across various operating systems (currently only Linux); Chimera loads the library according to your machine environment (It looks system properties, `os.name` and `os.arch`). 
  * Simple usage. Add the chimera-(version).jar file to your classpath.
  * [Apache License Version 2.0](http://www.apache.org/licenses/LICENSE-2.0). Free for both commercial and non-commercial use.

## Download
  * Release version: http://central.maven.org/maven2/com/intel/chimera/chimera/
  * Snapshot version (the latest beta version): https://oss.sonatype.org/content/repositories/snapshots/com/intel/chimera/chimera/

### Using with Maven
  * Chimera is available from Maven's central repository:  <http://central.maven.org/maven2/com/intel/chimera/chimera>

Add the following dependency to your pom.xml:

    <dependency>
      <groupId>com.intel.chimera</groupId>
      <artifactId>chimera</artifactId>
      <version>0.5.0</version>
      <type>jar</type>
      <scope>compile</scope>
    </dependency>

### Using with sbt

```
libraryDependencies += "com.intel.chimera" % "chimera" % "0.5.0"
```

## Usage 

```java
CryptoCodec codec = CryptoCodec.getInstance();
byte[] key = new byte[16];
byte[] iv = new byte[16];
int bufferSize = 4096;
String input = "hello world!";
byte[] decryptedData = new byte[1024];
// Encrypt
ByteArrayOutputStream os = new ByteArrayOutputStream();
CryptoOutputStream cos = new CryptoOutputStream(os, codec, bufferSize, key, iv);
cos.write(input.getBytes("UTF-8"));
cos.flush();
cos.close();

// Decrypt
CryptoInputStream cis = new CryptoInputStream(new ByteArrayInputStream(os.toByteArray()), codec, bufferSize, key, iv);
int decryptedLen = cis.read(decryptedData, 0, 1024);
```

### Configuration
Currently, two crypto codec are supported: JceAesCtrCryptoCodec and OpensslAesCtrCryptoCodec, you can configure which codec to use as follows:

    $ java -Dchimera.crypto.codec.classes.aes.ctr.nopadding=com.intel.chimera.OpensslAesCtrCryptoCodec Sample
    $ java -Dchimera.crypto.codec.classes.aes.ctr.nopadding=com.intel.chimera.JceAesCtrCryptoCodec Sample

{'fraction_non_alphanumeric': 0.11746617466174662, 'fraction_numerical': 0.012915129151291513, 'mean_word_length': 4.77396449704142, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4833805', 'n_tokens_mistral': 1588, 'n_tokens_neox': 1488, 'n_words': 416}