Skip to content

Commit f3e3f5f

Browse files
committed
Add syntax highlighting to README
1 parent 34714d0 commit f3e3f5f

File tree

1 file changed

+22
-24
lines changed

1 file changed

+22
-24
lines changed

README.md

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,26 @@ This is a collection of Django Model Field classes that are encrypted using [Key
1111
[Keyczar](http://www.keyczar.org/) is a crypto library that exposes a simple API by letting the user set things like the algorithm and key size right in the keyfile. It also provides for things like expiring old keys and cycling in new ones.
1212

1313
#### Getting Started
14-
15-
$ pip install django-encrypted-fields
16-
14+
```shell
15+
$ pip install django-encrypted-fields
16+
```
1717
Create a basic keyczar keyset. `AES-256` in this case.
18-
19-
$ mkdir fieldkeys
20-
$ keyczart create --location=fieldkeys --purpose=crypt
21-
$ keyczart addkey --location=fieldkeys --status=primary --size=256
22-
18+
```shell
19+
$ mkdir fieldkeys
20+
$ keyczart create --location=fieldkeys --purpose=crypt
21+
$ keyczart addkey --location=fieldkeys --status=primary --size=256
22+
```
2323
In your `settings.py`
24-
25-
ENCRYPTED_FIELDS_KEYDIR = '/path/to/fieldkeys'
26-
24+
```python
25+
ENCRYPTED_FIELDS_KEYDIR = '/path/to/fieldkeys'
26+
```
2727
Then, in `models.py`
28+
```python
29+
from encrypted_fields import EncryptedTextField
2830

29-
from encrypted_fields import EncryptedTextField
30-
31-
class MyModel(models.Model):
32-
text_field = EncryptedTextField()
33-
31+
class MyModel(models.Model):
32+
text_field = EncryptedTextField()
33+
```
3434
Use your model as normal and your data will be encrypted in the database.
3535

3636
_Warning:_ Once the data is encrypted, it can no longer to used to query or sort. In SQL, these will all look like text fields with random noise in them (which is what you want).
@@ -50,13 +50,11 @@ Currently build in and unit-tested fields. They have the save APIs as their non-
5050
#### Encrypt All The Fields!
5151

5252
Making new fields is easy! Django Encrypted Fields uses a handy mixin to make upgrading pre-existing fields quite easy.
53+
```python
54+
from django.db import models
55+
from encrypted_fields import EncryptedFieldMixin
5356

54-
from django.db import models
55-
from encrypted_fields import EncryptedFieldMixin
56-
57-
class EncryptedIPAddressField(EncryptedFieldMixin, models.IPAddressField):
58-
pass
59-
57+
class EncryptedIPAddressField(EncryptedFieldMixin, models.IPAddressField):
58+
pass
59+
```
6060
Please report an issues you encounter when trying this, since I've only tested it with the fields above.
61-
62-
Tips welcome. :) [13q4ZK9BgR4ZhKq27KmkuaEkay1GBEoUuS](https://coinbase.com/checkouts/5235423fe479cfc415f33635f75212fe)

0 commit comments

Comments
 (0)