https://github.com/ed-itsolutions/typeorm-encrypted-column
Provides a decorator for encrypted columns in TypeORM.
https://github.com/ed-itsolutions/typeorm-encrypted-column
decorators encrypted-columns encryption typeorm
Last synced: 11 months ago
JSON representation
Provides a decorator for encrypted columns in TypeORM.
- Host: GitHub
- URL: https://github.com/ed-itsolutions/typeorm-encrypted-column
- Owner: Ed-ITSolutions
- Created: 2018-09-27T16:08:48.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-01-04T21:37:25.000Z (over 3 years ago)
- Last Synced: 2025-07-03T20:06:11.448Z (12 months ago)
- Topics: decorators, encrypted-columns, encryption, typeorm
- Language: TypeScript
- Homepage:
- Size: 875 KB
- Stars: 5
- Watchers: 4
- Forks: 6
- Open Issues: 14
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
# Typeorm Encrypted Column
[](https://travis-ci.org/Ed-ITSolutions/typeorm-encrypted-column) [](https://coveralls.io/github/Ed-ITSolutions/typeorm-encrypted-column?branch=master)
Typeorm Encrypted Column is a replacement for [typeorm-encrypted](https://github.com/generalpiston/typeorm-encrypted).
## Differences
Typeorm Encrypted Column works slightly differently.
Typeorm Encrypted Column uses a decorator instead of retyping the options object passed to column. Using this decorator it validates the key and algorithm provided throwing an error if they are not valid. This moves config errors to startup not the first time the encrypted column is accessed.
## Usage
```ts
import {Entity, PrimaryGeneratedColumn, Column, createConnection} from 'typeorm'
import {Subscriber as EncryptedColumnSubscriber, EncryptedColumn} from 'typeorm-encrypted-column'
@Entity()
class ProtectedData{
@PrimaryGeneratedColumn()
id: number
@Column()
name: string
@EncryptedColumn({
encrypt: {
key: 'd85117047fd06d3afa79b6e44ee3a52eb426fc24c3a2e3667732e8da0342b4da',
algorithm: 'aes-256-cbc',
ivLength: 16,
looseMatching: false // If true existance of the column will not be checked.
}
})
}
let connection = createConnection({
...
entities: [ProtectedData],
subscribers: [EncryptedColumnSubscriber]
})
```
## Contributing
Pull requests and issues are welcome on this repository.
To build locally pull a copy of the repository and run npm install to get the dependecies.
Testing is done with `npm test` which will test the code.