https://github.com/elliotwutingfeng/fernet
A Dart library for encrypting and decrypting messages using the Fernet scheme.
https://github.com/elliotwutingfeng/fernet
aes-128-cbc cryptography decryption encryption hmac-sha256 pkcs7 secret
Last synced: 7 months ago
JSON representation
A Dart library for encrypting and decrypting messages using the Fernet scheme.
- Host: GitHub
- URL: https://github.com/elliotwutingfeng/fernet
- Owner: elliotwutingfeng
- License: bsd-3-clause
- Created: 2024-03-28T06:41:33.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-02-22T03:36:07.000Z (9 months ago)
- Last Synced: 2025-04-05T13:38:13.559Z (8 months ago)
- Topics: aes-128-cbc, cryptography, decryption, encryption, hmac-sha256, pkcs7, secret
- Language: Dart
- Homepage: https://pub.dev/packages/fernet
- Size: 31.3 KB
- Stars: 6
- Watchers: 0
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# fernet
[](https://pub.dev/packages/fernet)
[](https://coveralls.io/github/elliotwutingfeng/fernet?branch=main)
[](LICENSE)
A Dart library for encrypting and decrypting messages using the [Fernet](https://cryptography.io/en/latest/fernet) scheme.
This is a direct port of the Fernet implementation in the Python [cryptography](https://cryptography.io) library.
## Requirements
- **Dart SDK:** 3.6+
## Using passwords with Fernet
It is possible to use passwords with Fernet. To do this, you need to run the password through a key derivation function such as PBKDF2HMAC, bcrypt, scrypt, or argon2. An example with argon2id is provided at [example/password.dart](example/password.dart).
## Implementation
Fernet is built on top of a number of standard cryptographic primitives. Specifically it uses:
- AES in CBC mode with a 128-bit key for encryption; using PKCS7 padding.
- HMAC using SHA256 for authentication.
- Initialization vectors are generated using Random.secure().
For complete details consult the [specification](https://github.com/fernet/spec/blob/master/Spec.md).
The cryptographic primitives used in this library are provided by [pointycastle](https://pub.dev/packages/pointycastle).
## Limitations
Fernet is ideal for encrypting data that easily fits in memory. As a design feature it does not expose unauthenticated bytes. This means that the complete message contents must be available in memory, making Fernet generally unsuitable for very large files at this time.
## Credits
This library uses code from other open-source projects. The copyright statements of these open-source projects are listed in [CREDITS.md](CREDITS.md). Most of the documentation and implementation details have been adapted from the Python [cryptography](https://cryptography.io) library.