<commit_before># libgcrypt-rs

[![Build Status](https://travis-ci.org/gpg-rs/libgcrypt.svg?branch=master)](https://travis-ci.org/gpg-rs/libgcrypt)
[![LGPL-2.1 licensed](https://img.shields.io/crates/l/gcrypt.svg)](./COPYING)
[![Crates.io](https://img.shields.io/crates/v/gcrypt.svg)](https://crates.io/crates/gcrypt)

[Libgcrypt][upstream] bindings for Rust.

[Documentation][docs]

## Requirements

The wrapper is usable with libgcrypt 1.5.0 or later. Some features may require
a more recent version.

By default, the libgcrypt-sys crate will attempt to build the bundled version
of the library from source using autoconf, automake and various C build tools.
The `bundled` feature flag controls this functionality and can be disabled by
using `default-features = false` in dependent crates and/or overridden by
setting the environment variable `LIBGCRYPT_USE_BUNDLED` to the empty string,
`no`, `off`, or `false` to disable or anything else to enable. An existing
installation may be specified using `LIBGCRYPT_LIB_DIR`, `LIBGCRYPT_LIBS`,
`LIBGCRYPT_STATIC` (optional) and `LIBGCRYPT_INCLUDE`. Alternatively the path
to the libgcrypt configuration program (`libgcrypt-config`) may be specified
using `LIBGCRYPT_CONFIG`.

## Usage

Put this in your `Cargo.toml`:

```toml
[dependencies]
gcrypt = "0.6"
```

And this in your crate root:

```rust
extern crate gcrypt;
```

The library requires initialization before first use. The functions `init`,
`init_fips`, and `init_default` can be used to initialize the library. The
closure passed to the first two functions is used to configure the library. For
the third function a default configuration is used. More information on
configuration options can be found in the libgcrypt [documentation][upstream docs].

An example:

```rust
let token = gcrypt::init(|x| {
    x.disable_secmem();
});
```

Calling any function in the wrapper that requires initialization before one of
the initialization functions has been called will cause the wrapper to attempt
to initialize the library with a call to `init_default`.

[upstream]: https://www.gnu.org/software/libgcrypt/
[docs]: https://docs.rs/gcrypt
[upstream docs]: https://www.gnupg.org/documentation/manuals/gcrypt/Initializing-the-library.html#Initializing-the-library<commit_msg>Update build instructions in README.md<commit_after># libgcrypt-rs

[![Build Status][build]][ci]
[![crates.io version][version]][crate]
[![LGPL-2.1 licensed][license]](./COPYING)
[![downloads][downloads]][crate]

[Libgcrypt][upstream] bindings for Rust.

[Documentation][docs]

## Building
These crates require the libgcrypt library and its development files (e.g.,
headers, libgcrypt-config) to be installed. The buildscript will attempt to
detect the necessary information using the `libgcrypt-config` script
distributed with libgcrypt. If for whatever reason this does not work, the
required information can also be specified using one or more environment
variables:
- `LIBGCRYPT_INCLUDE` specifies the path(s) where header files can be found.
- `LIBGCRYPT_LIB_DIR` specifies the path(s) where library files (e.g., *.so, *.a,
  *.dll, etc.) can be found.
- `LIBGCRYPT_LIBS` specifies the name(s) of all required libraries.
- `LIBGCRYPT_STATIC` controls whether libraries are linked to statically or
  dynamically by default. Individual libraries can have their linkage
  overridden by prefixing their names with either `static=` or `dynamic=` in
  `LIBGCRYPT_LIBS`.
- `LIBGCRYPT_CONFIG` specifies the path to the `libgcrypt-config` script.

Each environment variable, with the exceptions of `LIBGCRYPT_STATIC` and
`LIBGCRYPT_CONFIG`, can take multiple values separated by the platform's path
separator.

**NOTE**: These crates also depend on the gpg-error crate which has its own
[requirements](https://github.com/gpg-rs/libgpg-error).

**NOTE**: Previous versions of these crates bundled the sources of the
libgcrypt library and attempted to build them via the buildscript. This is no
longer supported.

## Usage
The library requires initialization before first use. The functions `init`,
`init_fips`, and `init_default` can be used to initialize the library. The
closure passed to the first two functions is used to configure the library. For
the third function a default configuration is used. More information on
configuration options can be found in the libgcrypt [documentation][upstream docs].

An example:

```rust
let token = gcrypt::init(|x| {
    x.disable_secmem();
});
```

Calling any function in the wrapper that requires initialization before one of
the initialization functions has been called will cause the wrapper to attempt
to initialize the library with a call to `init_default`.

[crate]: https://crates.io/crates/gcrypt
[ci]: https://travis-ci.org/gpg-rs/libgcrypt
[build]: https://img.shields.io/travis/gpg-rs/libgcrypt/master?style=flat-square
[version]: https://img.shields.io/crates/v/gcrypt?style=flat-square
[license]: https://img.shields.io/crates/l/gcrypt?style=flat-square
[downloads]: https://img.shields.io/crates/d/gcrypt?style=flat-square

[upstream]: https://www.gnu.org/software/libgcrypt/
[docs]: https://docs.rs/gcrypt
[upstream docs]: https://www.gnupg.org/documentation/manuals/gcrypt/Initializing-the-library.html#Initializing-the-library
{'fraction_non_alphanumeric': 0.1064234131508932, 'fraction_numerical': 0.0017103762827822121, 'mean_word_length': 5.2729439809296785, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 18, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6212604', 'n_tokens_mistral': 1632, 'n_tokens_neox': 1539, 'n_words': 564}