flutter_stegify 0.0.6

  • Readme
  • Changelog
  • Example
  • Installing
  • 71

stegify-flutter-plugin #

Flutter plugin for fully transparent hiding any file within an image using stegify API. This technique is known as LSB (Least Significant Bit) steganography

Demonstration #

CarrierDataResult
Original FileEncoded FileEncoded File

The Result file contains the Data file hidden in it. And as you can see it is fully transparent.

Usage #

flutter-stegify plugin offers an easy to use Dart functions for steganography encodin/decoding. The original implementation is in Go and can be found here: stegify

This plugin uses go-mobile for generating platform native bindings and exposes Dart functions which can be used directly in your flutter mobile application!

In order to import this plugin correctly you need to add the following lines to your settings.gradle:

In the beginning add: include ':steg'

In the end of the file add: project(':steg').projectDir = new File(project(':flutter_stegify').projectDir, 'steg')

Example usage of the plugin can be found here.

API #

void encode(String carrierFileName, String dataFileName, String resultFileName) async
void decode(String carrierFileName, String resultFileName) async

encode performs steganography encoding of data file in carrier file and saves the steganography encoded product in new file.

decode performs steganography decoding of data previously encoded by the Encode function. The data is decoded from file carrier and it is saved in separate new file

NOTE: The result file won't have any file extension and therefore it should be specified explicitly in the resultFileName argument.

Disclaimer #

If carrier file is in jpeg or jpg format, after encoding the result file image will be png encoded (therefore it may be bigger in size) despite of file extension inherited from the original carrier file (which is .jpeg or .jpg).

0.0.1 #

flutter-stegify plugin offers an easy to use Dart functions for steganography encodin/decoding. The original implementation is in Go and can be found here: stegify

void encode(String carrierFileName, String dataFileName, String resultFileName) async
void decode(String carrierFileName, String resultFileName) async

encode performs steganography encoding of data file in carrier file and saves the steganography encoded product in new file.

decode performs steganography decoding of data previously encoded by the Encode function. The data is decoded from file carrier and it is saved in separate new file

NOTE: When encoding the file extension of result file is inherited from the carrier file and must not be specified explicitly in the resultFileName argument.

NOTE: When decoding the result file won't have any file extension and therefore it should be specified explicitly in the resultFileName argument.

0.0.3 #

Fix gradle setup.

0.0.4 #

Make the API async.

0.0.5 #

Improve usage documentation

In order to import this plugin correctly you need to add the following lines to your settings.gradle:

In the beginning add: include ':steg'

In the end of the file add: project(':steg').projectDir = new File(project(':flutter_stegify').projectDir, 'steg')

Example usage of the plugin can be found here.

0.0.6 #

Increase Kotlin version to 1.3.10

example/lib/main.dart

import 'dart:io';

import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/services.dart';
import 'package:flutter_stegify/flutter_stegify.dart';
import 'package:path_provider/path_provider.dart';

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: StegifyWidget(),
      ),
    );
  }
}

class StegifyWidget extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return StegifyState();
  }
}

class StegifyState extends State<StegifyWidget> {
  bool decode;
  Image image;

  @override
  void initState() {
    decode = false;
    _copyImageFromAsset("street.jpeg");
    _copyImageFromAsset("lake.jpeg");
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Column(children: <Widget>[
      SizedBox(height: 10),
      CupertinoButton(
        color: Colors.blue,
        child: Text(
          this.decode ? "Decode lake from street" : "Encode lake into street",
          style: TextStyle(
            color: Colors.white,
            fontWeight: FontWeight.bold,
          ),
        ),
        onPressed: () async {
          Directory directory = await getApplicationDocumentsDirectory();
          File streetImage = File(directory.path + "/street.jpeg");
          File lakeImage = File(directory.path + "/lake.jpeg");

          if (this.decode) {
            // Decode result.jpeg into ../decoded.jpeg (should be lake image)
            // Here in decode we specify the result file extension explicitly.
            await Stegify.decode(directory.path + "/result.jpeg",
                directory.path + "/decoded.jpeg");

            setState(() {
              this.decode = !this.decode;
              // Display the decoded image (should be lake image)
              image = Image.file(File(directory.path + "/decoded.jpeg"));
            });
          } else {
            // Encode lake image into the street image and save it under ../result.jpeg
            // the .jpeg extension comes from the carrier's extension (street.jpeg)
            await Stegify.encode(
                streetImage.path, lakeImage.path, directory.path + "/result");

            setState(() {
              this.decode = !this.decode;
              // Display the encoded image (should be street image with lake image hidden in it)
              image = Image.file(File(directory.path + "/result.jpeg"));
            });
          }
        },
      ),
      SizedBox(height: 10),
      Center(
        child: image,
      ),
      SizedBox(height: 10),
      Text(
        this.decode
            ? "Result street image with lake image hidden in it"
            : "Result lake image extracted from street image encoded with it",
        style: TextStyle(fontWeight: FontWeight.bold),
      ),
    ]);
  }

  void _copyImageFromAsset(String imageName) async {
    Directory directory = await getApplicationDocumentsDirectory();
    ByteData data = await rootBundle.load("assets/" + imageName);
    List<int> bytes =
        data.buffer.asUint8List(data.offsetInBytes, data.lengthInBytes);
    File(directory.path + "/" + imageName).writeAsBytes(bytes);
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  flutter_stegify: ^0.0.6

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_stegify/flutter_stegify.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
46
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
71
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_stegify/flutter_stegify.dart] that declares support for platforms: android, ios

Package does not support Flutter platform macos

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

Package does not support Flutter platform web

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

Package does not support Flutter platform windows

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

Package not compatible with SDK dart

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

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.

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