flutter_3des_plugin 0.0.3

  • Readme
  • Changelog
  • Example
  • Installing
  • new55

flutter_3des_plugin #

A new flutter plugin project.

Getting Started #

This project is a starting point for a Flutter plug-in package, a specialized package that includes platform-specific implementation code for Android and/or iOS.

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

Add Dependency (引入) #

dependencies:
  flutter_3des_plugin: ^0.0.3

Implementation (使用) #

import 'package:flutter_3des_plugin/flutter_3des_plugin.dart';

/*
 * 1. 目的: 该插件为 ECB模式 3des 加密, 解决 flutter => java后台 => 硬件 相联系的需求 (需保证App端、服务端、硬件三方加密结果一致);
 * 2. 现有的 pub.dev 插件如(flutter_3des, flutter_des, des_plugin)加密后的结果均和 java、硬件加密的结果不一致, 故诞生了这个3des加密插件。
 * 3. 后续加入解密, 以及base64模式加密、解密
 * 4. 有问题或者疑问,可前往 github (https://github.com/laijinxian/flutter_3des_plugin)提 Issues; 或者前往掘金(https://juejin.im/post/5eea1264e51d4574073b4a8a)留言
 */
void example() async {
  const data = "2005261620000123";
  const key = "FC1900000123200526162055AA5A5AA5";

  Flutter3desPlugin.encrypt(key, data).then((res) {
    // TODO: res就是加密后的数据
    print(res)
  });
}

0.0.1 #

  • TODO: Describe initial release.

0.0.2 #

  • TODO: modify README.md.

0.0.3 #

  • TODO: ios update.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'dart:async';

import 'package:flutter/services.dart';
import 'package:flutter_3des_plugin/flutter_3des_plugin.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _platformVersion = 'Unknown';
 
  // _data, _key 数据为测试数据, 实际开发根据项目需求规则生成
  final String _data = '2005261620000123';
  final String _key = 'FC1900000123200526162055AA5A5AA5';
  String _result  = '';

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

  // 3des 加密
  encrypt () {
    Flutter3desPlugin.encrypt(_key, _data).then((res) {
      // TODO: res就是加密后的数据
      setState(() {
        _result = res; 
      });
    });
  }

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    String platformVersion;
    // Platform messages may fail, so we use a try/catch PlatformException.
    try {
      platformVersion = await Flutter3desPlugin.platformVersion;
    } on PlatformException {
      platformVersion = 'Failed to get platform version.';
    }

    // If the widget was removed from the tree while the asynchronous platform
    // message was in flight, we want to discard the reply rather than calling
    // setState to update our non-existent appearance.
    if (!mounted) return;

    setState(() {
      _platformVersion = platformVersion;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('flutter 3des plugin example'),
        ),
        body: Center(
          child: new Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              new Text('Running on: $_platformVersion'),
              new Text('加密的data: $_data'),
              new Text('加密的key: $_key'),
              RaisedButton(
              onPressed: _result.isEmpty ? (){
                encrypt();
              } : null,
              child: Text("执行3des加密"),
            ),
              new Text('加密的结果: $_result'),
            ],
          ),
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  flutter_3des_plugin: ^0.0.3

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:flutter_3des_plugin/flutter_3des_plugin.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
19
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
77
Overall:
Weighted score of the above. [more]
55
Learn more about scoring.

We analyzed this package on Jul 11, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.15
  • Flutter: 1.17.5

Analysis suggestions

Package does not support Flutter platform Linux

Because:

  • package:flutter_3des_plugin/flutter_3des_plugin.dart that declares support for platforms: Android, iOS

Package does not support Flutter platform Web

Because:

  • package:flutter_3des_plugin/flutter_3des_plugin.dart that declares support for platforms: Android, iOS

Package does not support Flutter platform Windows

Because:

  • package:flutter_3des_plugin/flutter_3des_plugin.dart that declares support for platforms: Android, iOS

Package does not support Flutter platform macOS

Because:

  • package:flutter_3des_plugin/flutter_3des_plugin.dart that declares support for platforms: Android, iOS

Package not compatible with SDK dart

Because:

  • flutter_3des_plugin that is a package requiring null.

Health issues and suggestions

Document public APIs. (-1 points)

5 out of 5 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Format lib/flutter_3des_plugin.dart.

Run flutter format to format lib/flutter_3des_plugin.dart.

Maintenance suggestions

The package description is too short. (-13 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.12 1.14.13
meta 1.1.8 1.2.2
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8 2.1.0-nullsafety
Dev dependencies
flutter_test