Skip to content

Commit e915139

Browse files
authored
Merge pull request #1 from LamNguyen17/aes-algorithm
Aes algorithm
2 parents 470144b + 3ddbea8 commit e915139

32 files changed

+1300
-85
lines changed

.github/workflows/flutter.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Flutter CI
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- master
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Check out the repository
14+
uses: actions/checkout@v2
15+
16+
- name: Set up Flutter
17+
uses: subosito/flutter-action@v2
18+
with:
19+
flutter-version: '3.19.6'
20+
21+
- name: Cache Flutter dependencies
22+
uses: actions/cache@v3
23+
with:
24+
path: |
25+
~/.pub-cache
26+
flutter/bin/cache
27+
# key: ${{ runner.os }}-pub-cache-${{ hashFiles('pubspec.yaml') }}
28+
key: ${{ runner.os }}-flutter-${{ hashFiles('pubspec.yaml', 'pubspec.lock') }}
29+
restore-keys: |
30+
${{ runner.os }}-flutter-
31+
32+
- name: Install dependencies
33+
run: flutter pub get
34+
35+
- name: Run tests & generate coverage
36+
run: flutter test --coverage
37+
38+
- name: Upload coverage to Codecov
39+
uses: codecov/codecov-action@v2
40+
with:
41+
files: ./coverage/lcov.info
42+
flags: flutter
43+
name: code-coverage-report
44+
token: 2f59bcbb-7263-4e0c-9a37-e710e39705bb
45+
fail_ci_if_error: true

LICENSE

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,20 @@
1-
TODO: Add your license here.
1+
MIT License
2+
3+
Copyright (c) 2024 LamNguyen176
4+
Permission is hereby granted, free of charge, to any person obtaining a copy
5+
of this software and associated documentation files (the "Software"), to deal
6+
in the Software without restriction, including without limitation the rights
7+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
copies of the Software, and to permit persons to whom the Software is
9+
furnished to do so, subject to the following conditions:
10+
11+
The above copyright notice and this permission notice shall be included in all
12+
copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20+
SOFTWARE.

README.md

Lines changed: 130 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,135 @@
11
# flutter_crypto_algorithm
22

3-
A new Flutter plugin project.
3+
[![Native language](https://img.shields.io/badge/native_language-Kotlin_&_Swift-green)](https://pub.dev/packages/flutter_crypto_algorithm)
4+
[![Code cov](https://codecov.io/gh/LamNguyen17/flutter_crypto_algorithm/branch/master/graph/badge.svg)](https://app.codecov.io/github/LamNguyen17/flutter_crypto_algorithm/blob/master/lib)
5+
[![License](https://img.shields.io/badge/license-MIT-8A2BE2)](https://github.com/LamNguyen17/flutter_crypto_algorithm/blob/master/LICENSE)
6+
[![Author](https://img.shields.io/badge/author-Forest_Nguyen-f59642)](https://github.com/LamNguyen17)
7+
8+
A Flutter package for secure encryption algorithms, providing efficient tools for data protection and encryption operations
9+
10+
## Installation
11+
Run this command with Flutter:
12+
```sh
13+
flutter pub add encryption_algorithm
14+
```
15+
16+
## Usage
17+
### Methods
18+
#### 🚀 AES
19+
```dart
20+
import 'package:flutter_crypto_algorithm/flutter_crypto_algorithm.dart';
21+
```
22+
```dart
23+
void main() {
24+
runApp(const MyApp());
25+
}
26+
27+
class MyApp extends StatefulWidget {
28+
const MyApp({super.key});
29+
30+
@override
31+
State<MyApp> createState() => _MyAppState();
32+
}
33+
34+
class _MyAppState extends State<MyApp> {
35+
String _encrypt = '';
36+
String _decrypt = '';
37+
final _crypto = Crypto();
38+
39+
@override
40+
void initState() {
41+
super.initState();
42+
crypto();
43+
}
44+
45+
// Platform messages are asynchronous, so we initialize in an async method.
46+
Future<void> crypto() async {
47+
String encrypt;
48+
String decrypt;
49+
try {
50+
encrypt =
51+
await _crypto.encrypt('Hello123', 'Hello') ??
52+
'Unknown encrypt';
53+
decrypt = await _crypto.decrypt(encrypt, 'Hello') ??
54+
'Unknown decrypt';
55+
} on PlatformException {
56+
encrypt = 'Failed encrypt.';
57+
decrypt = 'Failed decrypt.';
58+
}
59+
if (!mounted) return;
60+
setState(() {
61+
_encrypt = encrypt;
62+
_decrypt = decrypt;
63+
});
64+
}
65+
66+
@override
67+
Widget build(BuildContext context) {
68+
return MaterialApp(
69+
home: Scaffold(
70+
appBar: AppBar(
71+
title: const Text('Flutter Crypto Algorithm'),
72+
),
73+
body: SingleChildScrollView(
74+
child: Column(
75+
children: [
76+
Section(title: 'AES', children: [
77+
_buildText('Encrypt: ', _encrypt),
78+
_buildText('Decrypt: ', _decrypt),
79+
]),
80+
],
81+
),
82+
),
83+
),
84+
);
85+
}
86+
87+
Widget _buildText(String label, String value) {
88+
return Text.rich(
89+
overflow: TextOverflow.ellipsis,
90+
maxLines: 2,
91+
TextSpan(
92+
text: label,
93+
style: const TextStyle(
94+
fontSize: 16, fontWeight: FontWeight.bold, color: Colors.red),
95+
children: [
96+
TextSpan(
97+
text: value,
98+
style: const TextStyle(
99+
fontSize: 16,
100+
fontWeight: FontWeight.normal,
101+
color: Colors.black),
102+
),
103+
],
104+
),
105+
);
106+
}
107+
}
108+
109+
class Section extends StatelessWidget {
110+
final String title;
111+
final List<Widget> children;
112+
113+
const Section({super.key, required this.title, required this.children});
114+
115+
@override
116+
Widget build(BuildContext context) {
117+
return Padding(
118+
padding: const EdgeInsets.all(16.0),
119+
child: Column(
120+
crossAxisAlignment: CrossAxisAlignment.start,
121+
children: [
122+
Text(
123+
title,
124+
style: const TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
125+
),
126+
...children,
127+
],
128+
),
129+
);
130+
}
131+
}
132+
```
4133

5134
## Getting Started
6135

android/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ android {
5050
}
5151

5252
dependencies {
53+
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.1'
54+
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.1'
5355
testImplementation 'org.jetbrains.kotlin:kotlin-test'
5456
testImplementation 'org.mockito:mockito-core:5.0.0'
5557
}
42.4 KB
Binary file not shown.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
4+
networkTimeout=10000
5+
validateDistributionUrl=true
6+
zipStoreBase=GRADLE_USER_HOME
7+
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)