Skip to content

Aes algorithm #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .github/workflows/flutter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Flutter CI

on:
pull_request:
branches:
- master

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Check out the repository
uses: actions/checkout@v2

- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: '3.19.6'

- name: Cache Flutter dependencies
uses: actions/cache@v3
with:
path: |
~/.pub-cache
flutter/bin/cache
# key: ${{ runner.os }}-pub-cache-${{ hashFiles('pubspec.yaml') }}
key: ${{ runner.os }}-flutter-${{ hashFiles('pubspec.yaml', 'pubspec.lock') }}
restore-keys: |
${{ runner.os }}-flutter-

- name: Install dependencies
run: flutter pub get

- name: Run tests & generate coverage
run: flutter test --coverage

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
with:
files: ./coverage/lcov.info
flags: flutter
name: code-coverage-report
token: 2f59bcbb-7263-4e0c-9a37-e710e39705bb
fail_ci_if_error: true
21 changes: 20 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1 +1,20 @@
TODO: Add your license here.
MIT License

Copyright (c) 2024 LamNguyen176
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
131 changes: 130 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,135 @@
# flutter_crypto_algorithm

A new Flutter plugin project.
[![Native language](https://img.shields.io/badge/native_language-Kotlin_&_Swift-green)](https://pub.dev/packages/flutter_crypto_algorithm)
[![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)
[![License](https://img.shields.io/badge/license-MIT-8A2BE2)](https://github.com/LamNguyen17/flutter_crypto_algorithm/blob/master/LICENSE)
[![Author](https://img.shields.io/badge/author-Forest_Nguyen-f59642)](https://github.com/LamNguyen17)

A Flutter package for secure encryption algorithms, providing efficient tools for data protection and encryption operations

## Installation
Run this command with Flutter:
```sh
flutter pub add encryption_algorithm
```

## Usage
### Methods
#### 🚀 AES
```dart
import 'package:flutter_crypto_algorithm/flutter_crypto_algorithm.dart';
```
```dart
void main() {
runApp(const MyApp());
}

class MyApp extends StatefulWidget {
const MyApp({super.key});

@override
State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
String _encrypt = '';
String _decrypt = '';
final _crypto = Crypto();

@override
void initState() {
super.initState();
crypto();
}

// Platform messages are asynchronous, so we initialize in an async method.
Future<void> crypto() async {
String encrypt;
String decrypt;
try {
encrypt =
await _crypto.encrypt('Hello123', 'Hello') ??
'Unknown encrypt';
decrypt = await _crypto.decrypt(encrypt, 'Hello') ??
'Unknown decrypt';
} on PlatformException {
encrypt = 'Failed encrypt.';
decrypt = 'Failed decrypt.';
}
if (!mounted) return;
setState(() {
_encrypt = encrypt;
_decrypt = decrypt;
});
}

@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Flutter Crypto Algorithm'),
),
body: SingleChildScrollView(
child: Column(
children: [
Section(title: 'AES', children: [
_buildText('Encrypt: ', _encrypt),
_buildText('Decrypt: ', _decrypt),
]),
],
),
),
),
);
}

Widget _buildText(String label, String value) {
return Text.rich(
overflow: TextOverflow.ellipsis,
maxLines: 2,
TextSpan(
text: label,
style: const TextStyle(
fontSize: 16, fontWeight: FontWeight.bold, color: Colors.red),
children: [
TextSpan(
text: value,
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.normal,
color: Colors.black),
),
],
),
);
}
}

class Section extends StatelessWidget {
final String title;
final List<Widget> children;

const Section({super.key, required this.title, required this.children});

@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
title,
style: const TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
),
...children,
],
),
);
}
}
```

## Getting Started

Expand Down
2 changes: 2 additions & 0 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ android {
}

dependencies {
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.1'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.1'
testImplementation 'org.jetbrains.kotlin:kotlin-test'
testImplementation 'org.mockito:mockito-core:5.0.0'
}
Expand Down
Binary file added android/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
7 changes: 7 additions & 0 deletions android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading
Loading