semvec/pypi-packages huggingface dataset:
flask-ctx 1.0.0
A simple integration of the CTX defense against side-channel attacks for Flask projects.
License: MIT
Keywords: flask ctx defense compression security BREACH

flask-ctx
==============

A simple integration of the CTX defense against side-channel attacks for Flask projects.

Requirements
============

- Python 2.5+
- Flask 0.10+
- ctx-defense

Installation
============

- Install the latest stable version using ``pip``:

```sh
pip install flask-ctx
```

Configuration
=============

- Import the *ctx_processor* function from ctx's context processors:
```python
from flask_ctx.context_processors import ctx_processor
```

- Add the *ctx_processor* in the application's context processors:
```python
app.context_processor(ctx_processor)
```

Basic Usage
===========

- Use the *ctx_protect* function to use ctx on secrets:
```html
{{ ctx_protect(secret, origin, alphabet) }}
```

*secret* is a string containing the secret that needs to be protected and *origin*
is a string uniquely identifying the CTX origin for the secret. *alphabet* is
an optional argument to define the alphabet that the secret belongs to, default
being the [ASCII_printable](https://docs.python.org/2/library/string.html#string.printable) characters.

- Add the *ctx_permutations* function to include the used permutations for each
  origin:
```html
{{ ctx_permutations() }}
```

The *ctx_permutations* function needs to run after all *ctx_protect* calls
that use an origin for the first time. It is proposed that it is included
before the *</body>* HTML tag.

- Include the ctx *client script* in the template:
```html
<script src="ctx.js"></script>
```

Example
=======

```html
<!DOCTYPE html>

<html>

<head>
  <meta charset="utf-8">
  <title>flask-ctx Example</title>
</head>

<body>
  This is a very sensitive secret: {{ ctx_protect("a secret", "origin1") }}
  This is another very sensitive secret: {{ ctx_protect("another secret", "origin2") }}

  {{ ctx_permutations() }}
  <script src="ctx.js"></script>
</body>

</html>
```
django-ctx 1.0.0
A simple integration of the CTX defense against side-channel attacks for Django projects.
License: MIT
Keywords: django ctx defense compression security BREACH

django-ctx
==============

A simple integration of the CTX defense against side-channel attacks for Django projects.

Requirements
============

- Python 2.5+
- Django 1.9+
- ctx-defense

Installation
============

- Install the latest stable version using ``pip``:

```sh
pip install django-ctx
```

Configuration
=============

- Add ctx to your *INSTALLED_APPS* setting:
```python
INSTALLED_APPS = (
    ...
    'django_ctx',
)
```

- Ctx processes the *context* for template requests, which is implemented using a
 *context processor*. Add the ctx processor to your *context_processors* setting:
```python
context_processors = (
    ...
    'django_ctx.context_processors.ctx_protect',
)
```

Basic Usage
===========

- Load the ctx tag library:
```html
{% load ctx_tags %}
```

- Use the *ctx_protect* tag to use ctx on secrets:
```html
{% ctx_protect secret origin alphabet %}
```

*secret* is a string containing the secret that needs to be protected and *origin*
is a string uniquely identifying the CTX origin for the secret. *alphabet* is
an optional argument to define the alphabet that the secret belongs to, default
being 'ASCII' which refers to the [ASCII
printable](https://docs.python.org/2/library/string.html#string.printable) characters.

- Add the *ctx_permutations* tag to include the used permutations for each
  origin:
```html
{% ctx_permutations %}
```
 The *ctx_permutations* tag needs to be included after all *ctx_protect* tags
 that use an origin for the first time. It is proposed that it is included
 before the *</body>* HTML tag.

- Include the ctx *client script* in the template:
```html
<script src="ctx.js"></script>
```

Example
=======
```html
<!DOCTYPE html>

<html>

<head>
  <meta charset="utf-8">
  <title>django-ctx Example</title>
</head>

<body>
  {% load ctx_tags %}

  This is a very sensitive secret from origin1: {% ctx_protect "my secret" "origin1" %}
  This is another very sensitive secret from origin2: {% ctx_protect "my other secret" "origin2" "ASCII_printable" %}

  {% ctx_permutations %}
  <script src="ctx.js"></script>
</body>

</html>
```
ctx-defense 1.0.0
The CTX defense library.
License: MIT
Keywords: ctx defense compression security BREACH

ctx
==============

The CTX defense library.

Installation
============

- Install the latest stable version using ``pip``:

```sh
pip install ctx-defense
```

Basic Usage
===========

- Import the CTX class from ctx and initialize the ctx object:
```python
from ctx_defense import CTX

ctx_object = CTX()
```

- Protect a secret from an origin with a specific alphabet:
```python
protected_secret = ctx_object.protect(secret, origin, alphabet)
```

- Retrieve the permutations for all origins:
```python
permutations = ctx_object.get_permutations()
```

- For more information on the CTX library and the classes it implements visit the defense's [website](https://github.com/dimkarakostas/ctx).

Example
=======

```python
from ctx_defense import CTX

secret = 'A secret string'
origin = 'user1'
alphabet = 'ASCII'

ctx_object = CTX()
protected_secret = ctx_object.protect(secret, origin, alphabet)
permutations = ctx_object.get_permutations()
```