dart_x3dh_e2e is a robust and secure project that focuses on implementing end-to-end encryption using the Extended Triple Diffie-Hellman (X3DH) key agreement protocol. The project aims to provide a reliable solution for secure communication, ensuring privacy and data integrity. It's designed with the vision of making the internet a safer place by enabling developers to easily integrate high-standard encryption into their applications.
This utility provides functions for encrypting and decrypting data using the AES-256-GCM encryption algorithm. It utilizes the cryptography
for encryption and decryption operations.
Ensure that you have Dart and Flutter installed on your machine. You can install them by following the instructions provided at https://flutter.dev/docs/get-started/install.
-
Add the
convert
andcryptography
crates as dependencies in yourpubspec.yaml
file:dependencies: convert: ^3.1.1 cryptography: ^2.7.0 ```
-
Import the required packages in your Dart code::
import 'dart:convert'; import 'package:convert/convert.dart'; import 'package:cryptography/cryptography.dart'; ```
-
Implement the
hexStringToBytes
function to convert a hexadecimal string to a byte list:List<int> hexStringToBytes(String hexString) { // Implementation details... } ```
-
Implement the
performEncryption
function to perform the encryption process:List<int> performEncryption(List<int> key, List<int> plaintext) { // Implementation details... } ```
-
Implement the
encryptWithHexStringKey
function to encrypt data using a shared secret key provided as a hexadecimal string:List<int> encryptWithHexStringKey(String sharedSecretKey, String plaintext) { // Implementation details... } ```
-
Implement the
encryptWithBytesKey
function to encrypt data using a shared secret key provided as a byte list:List<int> encryptWithBytesKey(List<int> sharedSecretKey, String plaintext) { // Implementation details... } ```
-
Implement the
decryptWithHexStringKey
function to decrypt data using a shared secret key provided as a hexadecimal string:String decryptWithHexStringKey(String sharedSecretKey, List<int> ciphertext, List<int> iv) { // Implementation details... } ```
-
Implement the
decryptWithBytesKey
function to decrypt data using a shared secret key provided as a byte list:String decryptWithBytesKey(List<int> sharedSecretKey, List<int> ciphertext, List<int> iv) { // Implementation details... } ```
-
Use the provided functions in your code to encrypt and decrypt data as needed.
void main() { const sharedSecretKey = '0123456789abcdef0123456789abcdef'; const plaintext = 'This is a secret message.'; final ciphertext = encryptWithHexStringKey(sharedSecretKey, plaintext); print('Ciphertext: $ciphertext'); final decryptedText = decryptWithHexStringKey(sharedSecretKey, ciphertext); print('Decrypted Text: $decryptedText'); } ``` Remember to replace `0123456789abcdef0123456789abcdef` with your actual shared secret key.
You can run tests for this project using the following command:
$ dart test/test.dart
The test results will be displayed in the console.
Performance BenchmarksTo measure the performance of this project, you can run benchmarks using the following command:
You can run bench for this project using the following command:
$ dart test/benchmark.dart
Contributions are welcome! If you find any issues or have suggestions for improvements, please feel free to open an issue or submit a pull request.
This project is licensed under the MIT License.
Feel free to customize the content according to your specific requirements and project details.