Skip to content

Commit a2d166c

Browse files
author
LamNguyen176
committed
update source method channel source IOS(#aes-algorithm)
1 parent 32f0426 commit a2d166c

File tree

16 files changed

+506
-55
lines changed

16 files changed

+506
-55
lines changed

.github/workflows/flutter.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
name: Flutter CI
22

33
on:
4-
push:
5-
branches:
6-
- aes-algorithm # Adjust this to your default branch if necessary
4+
# push:
5+
# branches:
6+
# - master
77
pull_request:
88
branches:
9-
- aes-algorithm
9+
- master
1010

1111
jobs:
1212
build:
@@ -19,7 +19,7 @@ jobs:
1919
- name: Set up Flutter
2020
uses: subosito/flutter-action@v2
2121
with:
22-
flutter-version: '3.19.6' # Specify the Flutter version, e.g., '2.10.0'
22+
flutter-version: '3.19.6'
2323

2424
- name: Cache Flutter dependencies
2525
uses: actions/cache@v3
@@ -42,5 +42,5 @@ jobs:
4242
files: ./coverage/lcov.info
4343
flags: flutter
4444
name: code-coverage-report
45-
token: 2f59bcbb-7263-4e0c-9a37-e710e39705bb # Add this to your GitHub secrets
45+
token: 2f59bcbb-7263-4e0c-9a37-e710e39705bb
4646
fail_ci_if_error: true

README.md

Lines changed: 118 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,128 @@
88
A Flutter package for secure encryption algorithms, providing efficient tools for data protection and encryption operations
99

1010
## Installation
11-
Run this command:
12-
With Flutter:
11+
Run this command with Flutter:
1312
```sh
1413
flutter pub add encryption_algorithm
1514
```
1615

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+
```
17133

18134
## Getting Started
19135

coverage/lcov.info

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,20 @@ DA:11,3
1515
DA:16,2
1616
DA:21,1
1717
DA:22,2
18-
DA:26,0
19-
DA:27,0
20-
DA:30,0
21-
DA:31,0
22-
LF:10
18+
LF:6
2319
LH:6
2420
end_of_record
2521
SF:lib/flutter_crypto_algorithm_method_channel.dart
26-
DA:12,1
27-
DA:15,3
28-
DA:25,1
29-
DA:28,3
30-
LF:4
31-
LH:4
22+
DA:13,1
23+
DA:17,3
24+
DA:18,1
25+
DA:19,1
26+
DA:20,0
27+
DA:27,1
28+
DA:31,3
29+
DA:32,1
30+
DA:33,1
31+
DA:34,0
32+
LF:10
33+
LH:8
3234
end_of_record

example/integration_test/plugin_integration_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ void main() {
1616
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
1717

1818
testWidgets('getPlatformVersion test', (WidgetTester tester) async {
19-
final FlutterCryptoAlgorithm plugin = FlutterCryptoAlgorithm();
19+
final Crypto plugin = Crypto();
2020
final String? encryptData = await plugin.encrypt('Hello123', 'Hello');
2121
// final String? version = await plugin.getPlatformVersion();
2222
// The version string depends on the host platform running the test, so

example/ios/Podfile.lock

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
PODS:
2+
- CryptoSwift (1.8.3)
3+
- Flutter (1.0.0)
4+
- flutter_crypto_algorithm (0.0.1):
5+
- CryptoSwift (= 1.8.3)
6+
- Flutter
7+
- RxSwift (= 6.7.1)
8+
- integration_test (0.0.1):
9+
- Flutter
10+
- RxSwift (6.7.1)
11+
12+
DEPENDENCIES:
13+
- Flutter (from `Flutter`)
14+
- flutter_crypto_algorithm (from `.symlinks/plugins/flutter_crypto_algorithm/ios`)
15+
- integration_test (from `.symlinks/plugins/integration_test/ios`)
16+
17+
SPEC REPOS:
18+
trunk:
19+
- CryptoSwift
20+
- RxSwift
21+
22+
EXTERNAL SOURCES:
23+
Flutter:
24+
:path: Flutter
25+
flutter_crypto_algorithm:
26+
:path: ".symlinks/plugins/flutter_crypto_algorithm/ios"
27+
integration_test:
28+
:path: ".symlinks/plugins/integration_test/ios"
29+
30+
SPEC CHECKSUMS:
31+
CryptoSwift: 967f37cea5a3294d9cce358f78861652155be483
32+
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
33+
flutter_crypto_algorithm: e0b5068b94eb0b67f3e86413a9a4bcc166650d5b
34+
integration_test: 13825b8a9334a850581300559b8839134b124670
35+
RxSwift: b9a93a26031785159e11abd40d1a55bcb8057e52
36+
37+
PODFILE CHECKSUM: 819463e6a0290f5a72f145ba7cde16e8b6ef0796
38+
39+
COCOAPODS: 1.15.2

0 commit comments

Comments
 (0)