flutter_3des 0.0.3

  • Readme
  • Changelog
  • Example
  • Installing
  • 74

flutter_3des #

A flutter implementation of Triple DES (3DES) algorithm. This plugin is an improvement of flutter_des

A comparison of Android/iOS result and that of CryptoJS

AndroidiOS
AndroidiOS
CryptoJS ImplementationCryptoJS Output
CryptoJS ImplementationCryptoJS Output

Getting Started #

Add Dependency #

dependencies:
  flutter_3des: #latest version

Implementation #


void example() async {
  const string = "my name is flutter";
  const key = "702040801020305070B0D1101020305070B0D1112110D0B0";
  const iv = "070B0D1101020305";

  var encrypt = await Flutter3des.encrypt(string, key, iv: iv);
  var decrypt = await Flutter3des.decrypt(encrypt, key, iv: iv);
  var encryptHex = await Flutter3des.encryptToHex(string, key, iv: iv);
  var decryptHex = await Flutter3des.decryptFromHex(encryptHex, key, iv: iv);
  var encryptBase64 = await Flutter3des.encryptToBase64(string, key, iv: iv);
  var decryptBase64 = await Flutter3des.decryptFromBase64(encryptBase64, key, iv: iv);
}```


0.0.1 #

  • TODO: Describe initial release.

0.0.2 #

  • added example

0.0.3 #

  • added detailed example with screenshot to README.md

example/lib/main.dart

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

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

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

const _string = "my name is flutter";

class _MyAppState extends State<MyApp> {
  static const _key = "702040801020305070B0D1101020305070B0D1112110D0B0";
  static const _iv = "070B0D1101020305";
  Uint8List _encrypt;
  String _decrypt = '';
  String _encryptHex = '';
  String _decryptHex = '';
  String _encryptBase64 = '';
  String _decryptBase64 = '';
  String _text = _string;

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

  @override
  void dispose() {
    super.dispose();
  }

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> init() async {
    if (_text.isEmpty) {
      _text = _string;
    }
    try {
      _encrypt = await Flutter3des.encrypt(_text, _key, iv: _iv);
      _decrypt = await Flutter3des.decrypt(_encrypt, _key, iv: _iv);
      _encryptHex = await Flutter3des.encryptToHex(_text, _key, iv: _iv);
      _decryptHex = await Flutter3des.decryptFromHex(_encryptHex, _key, iv: _iv);
      _encryptBase64 = await Flutter3des.encryptToBase64(_text, _key, iv: _iv);
      _decryptBase64 = await Flutter3des.decryptFromBase64(_encryptBase64, _key, iv: _iv);
      setState(() {});
    } catch (e) {
      print(e);
    }
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: Scaffold(
        appBar: AppBar(
          title: Text(
            'TripleDES (3DES)'
          ),
        ),
        body: Padding(
          padding: const EdgeInsets.all(15.0),
          child: Center(
            child: ListView(
              children: <Widget>[
                _row('KEY', _key),
                _row('IV', _iv),
                _row('String', _string),
                _row('Encrypted in Base64', _encryptBase64),
                _row('Encrypted in Byte Array', _encrypt.toString()),
                _row('Encrypted in Hex', _encryptHex),
              ],
            ),
          ),
        ),
      ),
    );
  }


  _row(String label, String value){
    return ListTile(
      title: Text(label, style: TextStyle(color: Colors.black54, fontSize: 14.0, fontWeight: FontWeight.w600),),
      subtitle: Text(value),
    );
  }

}

Use this package as a library

1. Depend on it

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


dependencies:
  flutter_3des: ^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/flutter_3des.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
54
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
85
Overall:
Weighted score of the above. [more]
74
Learn more about scoring.

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

  • Dart: 2.8.4
  • pana: 0.13.13
  • Flutter: 1.17.5

Analysis suggestions

Package does not support Flutter platform linux

Because of import path [package:flutter_3des/flutter_3des.dart] that declares support for platforms: android, ios

Package does not support Flutter platform macos

Because of import path [package:flutter_3des/flutter_3des.dart] that declares support for platforms: android, ios

Package does not support Flutter platform web

Because of import path [package:flutter_3des/flutter_3des.dart] that declares support for platforms: android, ios

Package does not support Flutter platform windows

Because of import path [package:flutter_3des/flutter_3des.dart] that declares support for platforms: android, ios

Package not compatible with SDK dart

because of import path [flutter_3des] that is in a package requiring null.

Health suggestions

Format lib/flutter_3des.dart.

Run flutter format to format lib/flutter_3des.dart.

Maintenance suggestions

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.

The package description is too short. (-5 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.

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
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8
Dev dependencies
flutter_test