├── .gitignore
├── .metadata
├── ACKNOWLEDGEMENTS.md
├── CHANGELOG.md
├── LICENSE
├── README.md
├── android
├── .gitignore
├── build.gradle
├── gradle.properties
├── gradle
│ └── wrapper
│ │ └── gradle-wrapper.properties
├── settings.gradle
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── firstfloorsoftware
│ │ └── flutter_sodium
│ │ └── FlutterSodiumPlugin.java
│ └── jniLibs
│ ├── arm64-v8a
│ └── libsodium.so
│ ├── armeabi-v7a
│ └── libsodium.so
│ ├── x86
│ └── libsodium.so
│ └── x86_64
│ └── libsodium.so
├── example
├── .gitignore
├── .metadata
├── README.md
├── android
│ ├── .gitignore
│ ├── app
│ │ ├── build.gradle
│ │ └── src
│ │ │ ├── debug
│ │ │ └── AndroidManifest.xml
│ │ │ ├── main
│ │ │ ├── AndroidManifest.xml
│ │ │ ├── kotlin
│ │ │ │ └── com
│ │ │ │ │ └── firstfloorsoftware
│ │ │ │ │ └── flutter_sodium_example
│ │ │ │ │ └── MainActivity.kt
│ │ │ └── res
│ │ │ │ ├── drawable
│ │ │ │ └── launch_background.xml
│ │ │ │ ├── mipmap-hdpi
│ │ │ │ └── ic_launcher.png
│ │ │ │ ├── mipmap-mdpi
│ │ │ │ └── ic_launcher.png
│ │ │ │ ├── mipmap-xhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ │ ├── mipmap-xxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ │ ├── mipmap-xxxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ │ └── values
│ │ │ │ └── styles.xml
│ │ │ └── profile
│ │ │ └── AndroidManifest.xml
│ ├── build.gradle
│ ├── gradle.properties
│ ├── gradle
│ │ └── wrapper
│ │ │ ├── gradle-wrapper.jar
│ │ │ └── gradle-wrapper.properties
│ ├── gradlew
│ ├── gradlew.bat
│ └── settings.gradle
├── assets
│ ├── fonts
│ │ └── RobotoMono-Regular.ttf
│ └── screenshots
│ │ └── screenshot1.png
├── example.md
├── flutter_sodium_example.iml
├── ios
│ ├── .gitignore
│ ├── Flutter
│ │ ├── AppFrameworkInfo.plist
│ │ ├── Debug.xcconfig
│ │ └── Release.xcconfig
│ ├── Podfile
│ ├── Podfile.lock
│ ├── Runner.xcodeproj
│ │ ├── project.pbxproj
│ │ ├── project.xcworkspace
│ │ │ └── contents.xcworkspacedata
│ │ └── xcshareddata
│ │ │ └── xcschemes
│ │ │ └── Runner.xcscheme
│ ├── Runner.xcworkspace
│ │ └── contents.xcworkspacedata
│ └── Runner
│ │ ├── AppDelegate.swift
│ │ ├── Assets.xcassets
│ │ ├── AppIcon.appiconset
│ │ │ ├── Contents.json
│ │ │ ├── Icon-App-1024x1024@1x.png
│ │ │ ├── Icon-App-20x20@1x.png
│ │ │ ├── Icon-App-20x20@2x.png
│ │ │ ├── Icon-App-20x20@3x.png
│ │ │ ├── Icon-App-29x29@1x.png
│ │ │ ├── Icon-App-29x29@2x.png
│ │ │ ├── Icon-App-29x29@3x.png
│ │ │ ├── Icon-App-40x40@1x.png
│ │ │ ├── Icon-App-40x40@2x.png
│ │ │ ├── Icon-App-40x40@3x.png
│ │ │ ├── Icon-App-60x60@2x.png
│ │ │ ├── Icon-App-60x60@3x.png
│ │ │ ├── Icon-App-76x76@1x.png
│ │ │ ├── Icon-App-76x76@2x.png
│ │ │ └── Icon-App-83.5x83.5@2x.png
│ │ └── LaunchImage.imageset
│ │ │ ├── Contents.json
│ │ │ ├── LaunchImage.png
│ │ │ ├── LaunchImage@2x.png
│ │ │ ├── LaunchImage@3x.png
│ │ │ └── README.md
│ │ ├── Base.lproj
│ │ ├── LaunchScreen.storyboard
│ │ └── Main.storyboard
│ │ ├── Info.plist
│ │ └── Runner-Bridging-Header.h
├── lib
│ ├── main.dart
│ ├── sample_widget.dart
│ ├── samples.dart
│ ├── toc.dart
│ └── topic_page.dart
├── macos
│ └── Podfile
├── pubspec.yaml
└── test
│ └── widget_test.dart
├── flutter_sodium.iml
├── ios
├── .gitignore
├── Classes
│ ├── FlutterSodiumPlugin.h
│ └── FlutterSodiumPlugin.m
├── flutter_sodium.podspec
└── libsodium.a
├── lib
├── flutter_sodium.dart
└── src
│ ├── bindings
│ ├── crypto_aead_bindings.dart
│ ├── crypto_auth_bindings.dart
│ ├── crypto_box_bindings.dart
│ ├── crypto_core_bindings.dart
│ ├── crypto_generichash_bindings.dart
│ ├── crypto_hash_bindings.dart
│ ├── crypto_kdf_bindings.dart
│ ├── crypto_kx_bindings.dart
│ ├── crypto_onetimeauth_bindings.dart
│ ├── crypto_pwhash_bindings.dart
│ ├── crypto_scalarmult_bindings.dart
│ ├── crypto_secretbox_bindings.dart
│ ├── crypto_secretstream_bindings.dart
│ ├── crypto_shorthash_bindings.dart
│ ├── crypto_sign_bindings.dart
│ ├── crypto_stream_bindings.dart
│ ├── libsodium.dart
│ ├── randombytes_bindings.dart
│ └── sodium_bindings.dart
│ ├── cha_cha20_poly1305.dart
│ ├── cha_cha20_poly1305_ietf.dart
│ ├── crypto_auth.dart
│ ├── crypto_box.dart
│ ├── crypto_sign.dart
│ ├── crypto_stream.dart
│ ├── detached_cipher.dart
│ ├── extensions.dart
│ ├── generic_hash.dart
│ ├── hash.dart
│ ├── init_push_result.dart
│ ├── key_derivation.dart
│ ├── key_exchange.dart
│ ├── key_pair.dart
│ ├── onetime_auth.dart
│ ├── password_hash.dart
│ ├── pull_result.dart
│ ├── random_bytes.dart
│ ├── scalar_mult.dart
│ ├── sealed_box.dart
│ ├── secret_box.dart
│ ├── session_keys.dart
│ ├── short_hash.dart
│ ├── sodium.dart
│ ├── sodium_exception.dart
│ └── x_cha_cha20_poly1305_ietf.dart
├── pubspec.yaml
└── test
└── flutter_sodium_test.dart
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | .atom/
3 | .idea
4 | .dart_tool/
5 | .packages
6 | .pub/
7 | .vscode/
8 | build/
9 | **/ios/.generated/
10 | **/ios/Flutter/.last_build_id
11 | packages
12 | pubspec.lock
13 |
--------------------------------------------------------------------------------
/.metadata:
--------------------------------------------------------------------------------
1 | # This file tracks properties of this Flutter project.
2 | # Used by Flutter tool to assess capabilities and perform upgrades etc.
3 | #
4 | # This file should be version controlled and should not be manually edited.
5 |
6 | version:
7 | revision: f139b11009aeb8ed2a3a3aa8b0066e482709dde3
8 | channel: stable
9 |
10 | project_type: plugin
11 |
--------------------------------------------------------------------------------
/ACKNOWLEDGEMENTS.md:
--------------------------------------------------------------------------------
1 | ## Acknowledgements
2 |
3 | The flutter_sodium plugin uses code from the following libraries:
4 |
5 | - [libsodium](https://github.com/jedisct1/libsodium), ISC license
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | ## 0.2.0 - March 12, 2021
2 | * migrates to ffi 1.0.0
3 | * stable null safety
4 |
5 | ## 0.2.0-nullsafety.1 - February 5, 2021
6 | * adds support for sodium_core_hchacha and hsalsa (merge 0.1.11)
7 |
8 | ## 0.2.0-nullsafety.0 - February 5, 2021
9 | * implements null safety
10 |
11 | ## 0.1.11 - February 5, 2021
12 | * adds support for loading libsodium on Linux and Windows
13 | * adds support for sodium_core_hchacha and hsalsa
14 |
15 | ## 0.1.10 - December 11, 2020
16 | * adds support for sodium_runtime_*, sodium_memcmp, sodium_pad and sodium_unpad
17 |
18 | ## 0.1.9 - October 31, 2020
19 | * sets Android build.gradle minSdkVersion 16, fixing implicit permissions READ_PHONE_STATE, READ_EXTERNAL_STORAGE and WRITE_EXTERNAL_STORAGE
20 |
21 | ## 0.1.8 - October 2, 2020
22 | * backwards incompatible Sodium.cryptoPwhashStr* changes, str return value and parameter type changed from ascii decoded String to null terminated Uint8List
23 |
24 | ## 0.1.7 - September 30, 2020
25 | * improves API documentation
26 | * removes obsolete convert package dependency
27 | * fixes Android deprecated API build warning
28 |
29 | ## 0.1.6 - September 30, 2020
30 | * fixes "cannot find symbol" compile error on Android
31 |
32 | ## 0.1.5 - September 30, 2020
33 | * fixes symbol lookup issue since flutter 1.20
34 | * fixes platforms key in pubspec.yaml
35 |
36 | ## 0.1.4 - September 16, 2020
37 | * adds sodium hex and base64 conversion helpers
38 | * removes sodium prefix from version and init functions (breaks API)
39 | * fixes generic_hash crash on Android
40 |
41 | ## 0.1.3 - July 17, 2020
42 | * reverts invalid multi-platform pubspec settings
43 |
44 | ## 0.1.2 - July 16, 2020
45 | * fixes documentation and multi-platform support warnings
46 |
47 | ## 0.1.1 - July 15, 2020
48 | * fixes "Failed to lookup symbol" errors on iOS in release mode.
49 |
50 | ## 0.1.0 - June 10, 2020
51 | * rewrite flutter_sodium using FFI
52 |
53 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | // Copyright 2020 First Floor Software. All rights reserved.
2 | //
3 | // Redistribution and use in source and binary forms, with or without
4 | // modification, are permitted provided that the following conditions are
5 | // met:
6 | //
7 | // * Redistributions of source code must retain the above copyright
8 | // notice, this list of conditions and the following disclaimer.
9 | // * Redistributions in binary form must reproduce the above
10 | // copyright notice, this list of conditions and the following disclaimer
11 | // in the documentation and/or other materials provided with the
12 | // distribution.
13 | // * Neither the name of First Floor Software nor the names of its
14 | // contributors may be used to endorse or promote products derived from
15 | // this software without specific prior written permission.
16 | //
17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # flutter_sodium
2 |
3 | With flutter_sodium you get access to the modern, easy-to-use [libsodium](https://download.libsodium.org/doc/) crypto library in your [Flutter](https://flutter.io) apps. One set of crypto APIs supporting both Android and iOS.
4 |
5 | [](https://pub.dartlang.org/packages/flutter_sodium)
6 |
7 | ## Getting Started
8 |
9 | In your flutter project add the dependency:
10 |
11 | ```yml
12 | dependencies:
13 | ...
14 | flutter_sodium: ^0.2.0
15 | ```
16 |
17 | Import the plugin and initialize it. Sodium.init() initializes the plugin and should be called before any other function provided by flutter_sodium.
18 |
19 | ```dart
20 | import 'package:flutter_sodium/flutter_sodium.dart';
21 |
22 | // initialize sodium
23 | Sodium.init();
24 | ```
25 |
26 | ## Usage example
27 |
28 | ```dart
29 | // Password hashing (using Argon)
30 | final password = 'my password';
31 | final str = PasswordHash.hashStringStorage(password);
32 |
33 | print(str);
34 |
35 | // verify hash str
36 | final valid = PasswordHash.verifyStorage(str, password);
37 |
38 | assert(valid);
39 | ```
40 |
41 | This project includes an extensive example app with runnable code samples. Be sure to check it out!
42 |
43 |
44 |
45 | ## API coverage
46 | The flutter_sodium plugin implements the following libsodium APIs:
47 | - crypto_aead
48 | - crypto_auth
49 | - crypto_box
50 | - crypto_generichash
51 | - crypto_hash
52 | - crypto_kdf
53 | - crypto_kx
54 | - crypto_onetimeauth
55 | - crypto_pwhash
56 | - crypto_scalarmult
57 | - crypto_secretbox
58 | - crypto_secretstream
59 | - crypto_shorthash
60 | - crypto_sign
61 | - crypto_stream
62 | - randombytes
63 | - sodium_version
64 |
65 | API coverage is not 100% complete, track the progress in [issue #61](https://github.com/firstfloorsoftware/flutter_sodium/issues/61)
66 |
67 | ## Dart APIs
68 | The plugin includes a core API that maps native libsodium functions 1:1 to Dart equivalents. The core API is available in the class [`Sodium`](https://github.com/firstfloorsoftware/flutter_sodium/blob/master/lib/flutter_sodium.dart). Dart naming conventions are used for core API function names. A native libsodium function such as `crypto_pwhash_str`, is available in flutter as `Sodium.cryptoPwhashStr`.
69 |
70 | Also included in flutter_sodium is a high-level, opinionated API providing access to libsodium in a Dart friendly manner. The various functions are available in separate Dart classes. Password hashing for example is available in the `PasswordHash` class. The high-level API depends on the core API to get things done.
71 |
72 | ## Migrating to fluttter_sodium FFI
73 | The FFI implementation of flutter_sodium is backwards incompatible with the previous platform channel implementation. The list of changes:
74 | - the entire FFI API is now synchronous, while the previous implementation was entirely asynchronous
75 | - all hardcoded libsodium constants are now available as properties on the Sodium class.
76 | - in the platform channel versions the Android and iOS implementations were not in sync. Some functions were available only in iOS, others only in Android. With the FFI implementation, there is a single API covering both platforms.
77 |
78 | ## Background threads
79 | Since the entire FFI API is synchronous, you'll need to do some extra work to execute long running crypto function on a background thread. Luckily this is very easy with Flutter's [compute function](https://api.flutter.dev/flutter/foundation/compute.html).
80 |
81 | The following code snippet demonstrates running a password hash on the background thread.
82 |
83 | ```dart
84 | final pw = 'hello world';
85 | final str = await compute(PasswordHash.hashStringStorageModerate, pw);
86 |
87 | print(str);
88 | ```
89 |
--------------------------------------------------------------------------------
/android/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 |
--------------------------------------------------------------------------------
/android/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | android {
3 | compileSdkVersion 28
4 | defaultConfig {
5 | minSdkVersion 16
6 | }
7 | }
8 |
9 | dependencies {
10 | }
11 |
--------------------------------------------------------------------------------
/android/gradle.properties:
--------------------------------------------------------------------------------
1 | org.gradle.jvmargs=-Xmx1536M
2 | android.enableR8=true
3 | android.useAndroidX=true
4 | android.enableJetifier=true
5 |
--------------------------------------------------------------------------------
/android/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | zipStoreBase=GRADLE_USER_HOME
4 | zipStorePath=wrapper/dists
5 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip
6 |
--------------------------------------------------------------------------------
/android/settings.gradle:
--------------------------------------------------------------------------------
1 | rootProject.name = 'flutter_sodium'
2 |
--------------------------------------------------------------------------------
/android/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
--------------------------------------------------------------------------------
/android/src/main/java/com/firstfloorsoftware/flutter_sodium/FlutterSodiumPlugin.java:
--------------------------------------------------------------------------------
1 | package com.firstfloorsoftware.flutter_sodium;
2 |
3 | import androidx.annotation.NonNull;
4 |
5 | import io.flutter.embedding.engine.plugins.FlutterPlugin;
6 | import io.flutter.plugin.common.MethodCall;
7 | import io.flutter.plugin.common.MethodChannel;
8 | import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
9 | import io.flutter.plugin.common.MethodChannel.Result;
10 | import io.flutter.plugin.common.PluginRegistry.Registrar;
11 |
12 | /** FlutterSodiumPlugin */
13 | public class FlutterSodiumPlugin implements FlutterPlugin, MethodCallHandler {
14 | /// The MethodChannel that will the communication between Flutter and native Android
15 | ///
16 | /// This local reference serves to register the plugin with the Flutter Engine and unregister it
17 | /// when the Flutter Engine is detached from the Activity
18 | private MethodChannel channel;
19 |
20 | @Override
21 | public void onAttachedToEngine(@NonNull FlutterPluginBinding flutterPluginBinding) {
22 | channel = new MethodChannel(flutterPluginBinding.getBinaryMessenger(), "sodium");
23 | channel.setMethodCallHandler(this);
24 | }
25 |
26 | // This static function is optional and equivalent to onAttachedToEngine. It supports the old
27 | // pre-Flutter-1.12 Android projects. You are encouraged to continue supporting
28 | // plugin registration via this function while apps migrate to use the new Android APIs
29 | // post-flutter-1.12 via https://flutter.dev/go/android-project-migration.
30 | //
31 | // It is encouraged to share logic between onAttachedToEngine and registerWith to keep
32 | // them functionally equivalent. Only one of onAttachedToEngine or registerWith will be called
33 | // depending on the user's project. onAttachedToEngine or registerWith must both be defined
34 | // in the same class.
35 | public static void registerWith(Registrar registrar) {
36 | final MethodChannel channel = new MethodChannel(registrar.messenger(), "sodium");
37 | channel.setMethodCallHandler(new FlutterSodiumPlugin());
38 | }
39 |
40 | @Override
41 | public void onMethodCall(@NonNull MethodCall call, @NonNull Result result) {
42 | if (call.method.equals("getPlatformVersion")) {
43 | result.success("Android " + android.os.Build.VERSION.RELEASE);
44 | } else {
45 | result.notImplemented();
46 | }
47 | }
48 |
49 | @Override
50 | public void onDetachedFromEngine(@NonNull FlutterPluginBinding binding) {
51 | channel.setMethodCallHandler(null);
52 | }
53 | }
--------------------------------------------------------------------------------
/android/src/main/jniLibs/arm64-v8a/libsodium.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/firstfloorsoftware/flutter_sodium/73171341a43ebb9041b15c6fe43e620d0e281d93/android/src/main/jniLibs/arm64-v8a/libsodium.so
--------------------------------------------------------------------------------
/android/src/main/jniLibs/armeabi-v7a/libsodium.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/firstfloorsoftware/flutter_sodium/73171341a43ebb9041b15c6fe43e620d0e281d93/android/src/main/jniLibs/armeabi-v7a/libsodium.so
--------------------------------------------------------------------------------
/android/src/main/jniLibs/x86/libsodium.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/firstfloorsoftware/flutter_sodium/73171341a43ebb9041b15c6fe43e620d0e281d93/android/src/main/jniLibs/x86/libsodium.so
--------------------------------------------------------------------------------
/android/src/main/jniLibs/x86_64/libsodium.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/firstfloorsoftware/flutter_sodium/73171341a43ebb9041b15c6fe43e620d0e281d93/android/src/main/jniLibs/x86_64/libsodium.so
--------------------------------------------------------------------------------
/example/.gitignore:
--------------------------------------------------------------------------------
1 | # Miscellaneous
2 | *.class
3 | *.log
4 | *.pyc
5 | *.swp
6 | .DS_Store
7 | .atom/
8 | .buildlog/
9 | .history
10 | .svn/
11 |
12 | # IntelliJ related
13 | *.iml
14 | *.ipr
15 | *.iws
16 | .idea/
17 |
18 | # The .vscode folder contains launch configuration and tasks you configure in
19 | # VS Code which you may wish to be included in version control, so this line
20 | # is commented out by default.
21 | #.vscode/
22 |
23 | # Flutter/Dart/Pub related
24 | **/doc/api/
25 | .dart_tool/
26 | .flutter-plugins
27 | .flutter-plugins-dependencies
28 | .packages
29 | .pub-cache/
30 | .pub/
31 | /build/
32 |
33 | # Web related
34 | lib/generated_plugin_registrant.dart
35 |
36 | # Exceptions to above rules.
37 | !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
38 |
--------------------------------------------------------------------------------
/example/.metadata:
--------------------------------------------------------------------------------
1 | # This file tracks properties of this Flutter project.
2 | # Used by Flutter tool to assess capabilities and perform upgrades etc.
3 | #
4 | # This file should be version controlled and should not be manually edited.
5 |
6 | version:
7 | revision: f139b11009aeb8ed2a3a3aa8b0066e482709dde3
8 | channel: stable
9 |
10 | project_type: app
11 |
--------------------------------------------------------------------------------
/example/README.md:
--------------------------------------------------------------------------------
1 | # flutter_sodium_example
2 |
3 | Demonstrates how to use the flutter_sodium plugin.
4 |
--------------------------------------------------------------------------------
/example/android/.gitignore:
--------------------------------------------------------------------------------
1 | gradle-wrapper.jar
2 | /.gradle
3 | /captures/
4 | /gradlew
5 | /gradlew.bat
6 | /local.properties
7 | GeneratedPluginRegistrant.java
8 |
--------------------------------------------------------------------------------
/example/android/app/build.gradle:
--------------------------------------------------------------------------------
1 | def localProperties = new Properties()
2 | def localPropertiesFile = rootProject.file('local.properties')
3 | if (localPropertiesFile.exists()) {
4 | localPropertiesFile.withReader('UTF-8') { reader ->
5 | localProperties.load(reader)
6 | }
7 | }
8 |
9 | def flutterRoot = localProperties.getProperty('flutter.sdk')
10 | if (flutterRoot == null) {
11 | throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
12 | }
13 |
14 | def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
15 | if (flutterVersionCode == null) {
16 | flutterVersionCode = '1'
17 | }
18 |
19 | def flutterVersionName = localProperties.getProperty('flutter.versionName')
20 | if (flutterVersionName == null) {
21 | flutterVersionName = '1.0'
22 | }
23 |
24 | apply plugin: 'com.android.application'
25 | apply plugin: 'kotlin-android'
26 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
27 |
28 | android {
29 | compileSdkVersion 28
30 |
31 | sourceSets {
32 | main.java.srcDirs += 'src/main/kotlin'
33 | }
34 |
35 | lintOptions {
36 | disable 'InvalidPackage'
37 | }
38 |
39 | defaultConfig {
40 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
41 | applicationId "com.firstfloorsoftware.flutter_sodium_example"
42 | minSdkVersion 16
43 | targetSdkVersion 28
44 | versionCode flutterVersionCode.toInteger()
45 | versionName flutterVersionName
46 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
47 | }
48 |
49 | buildTypes {
50 | release {
51 | // TODO: Add your own signing config for the release build.
52 | // Signing with the debug keys for now, so `flutter run --release` works.
53 | signingConfig signingConfigs.debug
54 | }
55 | }
56 | }
57 |
58 | flutter {
59 | source '../..'
60 | }
61 |
62 | dependencies {
63 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
64 | testImplementation 'junit:junit:4.12'
65 | androidTestImplementation 'androidx.test:runner:1.1.1'
66 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
67 | }
68 |
--------------------------------------------------------------------------------
/example/android/app/src/debug/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/example/android/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
8 |
12 |
19 |
20 |
21 |
22 |
23 |
24 |
26 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/example/android/app/src/main/kotlin/com/firstfloorsoftware/flutter_sodium_example/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package com.firstfloorsoftware.flutter_sodium_example
2 |
3 | import androidx.annotation.NonNull;
4 | import io.flutter.embedding.android.FlutterActivity
5 | import io.flutter.embedding.engine.FlutterEngine
6 | import io.flutter.plugins.GeneratedPluginRegistrant
7 |
8 | class MainActivity: FlutterActivity() {
9 | override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) {
10 | GeneratedPluginRegistrant.registerWith(flutterEngine);
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/example/android/app/src/main/res/drawable/launch_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
12 |
13 |
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/firstfloorsoftware/flutter_sodium/73171341a43ebb9041b15c6fe43e620d0e281d93/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/firstfloorsoftware/flutter_sodium/73171341a43ebb9041b15c6fe43e620d0e281d93/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/firstfloorsoftware/flutter_sodium/73171341a43ebb9041b15c6fe43e620d0e281d93/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/firstfloorsoftware/flutter_sodium/73171341a43ebb9041b15c6fe43e620d0e281d93/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/firstfloorsoftware/flutter_sodium/73171341a43ebb9041b15c6fe43e620d0e281d93/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
9 |
--------------------------------------------------------------------------------
/example/android/app/src/profile/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/example/android/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | ext.kotlin_version = '1.3.50'
3 | repositories {
4 | google()
5 | jcenter()
6 | }
7 |
8 | dependencies {
9 | classpath 'com.android.tools.build:gradle:3.5.0'
10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
11 | }
12 | }
13 |
14 | allprojects {
15 | repositories {
16 | google()
17 | jcenter()
18 | }
19 | }
20 |
21 | rootProject.buildDir = '../build'
22 | subprojects {
23 | project.buildDir = "${rootProject.buildDir}/${project.name}"
24 | }
25 | subprojects {
26 | project.evaluationDependsOn(':app')
27 | }
28 |
29 | task clean(type: Delete) {
30 | delete rootProject.buildDir
31 | }
32 |
--------------------------------------------------------------------------------
/example/android/gradle.properties:
--------------------------------------------------------------------------------
1 | org.gradle.jvmargs=-Xmx1536M
2 | android.enableR8=true
3 | android.useAndroidX=true
4 | android.enableJetifier=true
5 |
--------------------------------------------------------------------------------
/example/android/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/firstfloorsoftware/flutter_sodium/73171341a43ebb9041b15c6fe43e620d0e281d93/example/android/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/example/android/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri Jun 23 08:50:38 CEST 2017
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip
7 |
--------------------------------------------------------------------------------
/example/android/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/example/android/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/example/android/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
3 | def flutterProjectRoot = rootProject.projectDir.parentFile.toPath()
4 |
5 | def plugins = new Properties()
6 | def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins')
7 | if (pluginsFile.exists()) {
8 | pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) }
9 | }
10 |
11 | plugins.each { name, path ->
12 | def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile()
13 | include ":$name"
14 | project(":$name").projectDir = pluginDirectory
15 | }
16 |
--------------------------------------------------------------------------------
/example/assets/fonts/RobotoMono-Regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/firstfloorsoftware/flutter_sodium/73171341a43ebb9041b15c6fe43e620d0e281d93/example/assets/fonts/RobotoMono-Regular.ttf
--------------------------------------------------------------------------------
/example/assets/screenshots/screenshot1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/firstfloorsoftware/flutter_sodium/73171341a43ebb9041b15c6fe43e620d0e281d93/example/assets/screenshots/screenshot1.png
--------------------------------------------------------------------------------
/example/example.md:
--------------------------------------------------------------------------------
1 | ```dart
2 | import 'package:flutter_sodium/flutter_sodium.dart';
3 |
4 | // initialize sodium (one-time)
5 | Sodium.init();
6 |
7 | // Password hashing (using Argon)
8 | final password = 'my password';
9 | final str = PasswordHash.hashStringStorage(password);
10 |
11 | print(str);
12 |
13 | // verify hash str
14 | final valid = PasswordHash.verifyStorage(str, password);
15 |
16 | assert(valid);
17 | ```
18 |
--------------------------------------------------------------------------------
/example/flutter_sodium_example.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/example/ios/.gitignore:
--------------------------------------------------------------------------------
1 | *.mode1v3
2 | *.mode2v3
3 | *.moved-aside
4 | *.pbxuser
5 | *.perspectivev3
6 | **/*sync/
7 | .sconsign.dblite
8 | .tags*
9 | **/.vagrant/
10 | **/DerivedData/
11 | Icon?
12 | **/Pods/
13 | **/.symlinks/
14 | profile
15 | xcuserdata
16 | **/.generated/
17 | Flutter/App.framework
18 | Flutter/Flutter.framework
19 | Flutter/Flutter.podspec
20 | Flutter/Generated.xcconfig
21 | Flutter/app.flx
22 | Flutter/app.zip
23 | Flutter/flutter_assets/
24 | Flutter/flutter_export_environment.sh
25 | ServiceDefinitions.json
26 | Runner/GeneratedPluginRegistrant.*
27 |
28 | # Exceptions to above rules.
29 | !default.mode1v3
30 | !default.mode2v3
31 | !default.pbxuser
32 | !default.perspectivev3
33 |
--------------------------------------------------------------------------------
/example/ios/Flutter/AppFrameworkInfo.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
7 | CFBundleExecutable
8 | App
9 | CFBundleIdentifier
10 | io.flutter.flutter.app
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | App
15 | CFBundlePackageType
16 | FMWK
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1.0
23 | MinimumOSVersion
24 | 8.0
25 |
26 |
27 |
--------------------------------------------------------------------------------
/example/ios/Flutter/Debug.xcconfig:
--------------------------------------------------------------------------------
1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
2 | #include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
3 | #include "Generated.xcconfig"
4 |
--------------------------------------------------------------------------------
/example/ios/Flutter/Release.xcconfig:
--------------------------------------------------------------------------------
1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
2 | #include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
3 | #include "Generated.xcconfig"
4 |
--------------------------------------------------------------------------------
/example/ios/Podfile:
--------------------------------------------------------------------------------
1 | # Uncomment this line to define a global platform for your project
2 | # platform :ios, '9.0'
3 |
4 | # CocoaPods analytics sends network stats synchronously affecting flutter build latency.
5 | ENV['COCOAPODS_DISABLE_STATS'] = 'true'
6 |
7 | project 'Runner', {
8 | 'Debug' => :debug,
9 | 'Profile' => :release,
10 | 'Release' => :release,
11 | }
12 |
13 | def flutter_root
14 | generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
15 | unless File.exist?(generated_xcode_build_settings_path)
16 | raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
17 | end
18 |
19 | File.foreach(generated_xcode_build_settings_path) do |line|
20 | matches = line.match(/FLUTTER_ROOT\=(.*)/)
21 | return matches[1].strip if matches
22 | end
23 | raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
24 | end
25 |
26 | require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
27 |
28 | flutter_ios_podfile_setup
29 |
30 | target 'Runner' do
31 | use_frameworks!
32 | use_modular_headers!
33 |
34 | flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
35 | end
36 |
37 | post_install do |installer|
38 | installer.pods_project.targets.each do |target|
39 | flutter_additional_ios_build_settings(target)
40 | end
41 | end
42 |
--------------------------------------------------------------------------------
/example/ios/Podfile.lock:
--------------------------------------------------------------------------------
1 | PODS:
2 | - Flutter (1.0.0)
3 | - flutter_sodium (0.0.1):
4 | - Flutter
5 | - url_launcher (0.0.1):
6 | - Flutter
7 |
8 | DEPENDENCIES:
9 | - Flutter (from `Flutter`)
10 | - flutter_sodium (from `.symlinks/plugins/flutter_sodium/ios`)
11 | - url_launcher (from `.symlinks/plugins/url_launcher/ios`)
12 |
13 | EXTERNAL SOURCES:
14 | Flutter:
15 | :path: Flutter
16 | flutter_sodium:
17 | :path: ".symlinks/plugins/flutter_sodium/ios"
18 | url_launcher:
19 | :path: ".symlinks/plugins/url_launcher/ios"
20 |
21 | SPEC CHECKSUMS:
22 | Flutter: 434fef37c0980e73bb6479ef766c45957d4b510c
23 | flutter_sodium: c84426b4de738514b5b66cfdeb8a06634e72fe0b
24 | url_launcher: 6fef411d543ceb26efce54b05a0a40bfd74cbbef
25 |
26 | PODFILE CHECKSUM: aafe91acc616949ddb318b77800a7f51bffa2a4c
27 |
28 | COCOAPODS: 1.10.1
29 |
--------------------------------------------------------------------------------
/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
32 |
33 |
39 |
40 |
41 |
42 |
43 |
44 |
54 |
56 |
62 |
63 |
64 |
65 |
66 |
67 |
73 |
75 |
81 |
82 |
83 |
84 |
86 |
87 |
90 |
91 |
92 |
--------------------------------------------------------------------------------
/example/ios/Runner.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/example/ios/Runner/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | import UIKit
2 | import Flutter
3 |
4 | @UIApplicationMain
5 | @objc class AppDelegate: FlutterAppDelegate {
6 | override func application(
7 | _ application: UIApplication,
8 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
9 | ) -> Bool {
10 | GeneratedPluginRegistrant.register(with: self)
11 | return super.application(application, didFinishLaunchingWithOptions: launchOptions)
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "size" : "20x20",
5 | "idiom" : "iphone",
6 | "filename" : "Icon-App-20x20@2x.png",
7 | "scale" : "2x"
8 | },
9 | {
10 | "size" : "20x20",
11 | "idiom" : "iphone",
12 | "filename" : "Icon-App-20x20@3x.png",
13 | "scale" : "3x"
14 | },
15 | {
16 | "size" : "29x29",
17 | "idiom" : "iphone",
18 | "filename" : "Icon-App-29x29@1x.png",
19 | "scale" : "1x"
20 | },
21 | {
22 | "size" : "29x29",
23 | "idiom" : "iphone",
24 | "filename" : "Icon-App-29x29@2x.png",
25 | "scale" : "2x"
26 | },
27 | {
28 | "size" : "29x29",
29 | "idiom" : "iphone",
30 | "filename" : "Icon-App-29x29@3x.png",
31 | "scale" : "3x"
32 | },
33 | {
34 | "size" : "40x40",
35 | "idiom" : "iphone",
36 | "filename" : "Icon-App-40x40@2x.png",
37 | "scale" : "2x"
38 | },
39 | {
40 | "size" : "40x40",
41 | "idiom" : "iphone",
42 | "filename" : "Icon-App-40x40@3x.png",
43 | "scale" : "3x"
44 | },
45 | {
46 | "size" : "60x60",
47 | "idiom" : "iphone",
48 | "filename" : "Icon-App-60x60@2x.png",
49 | "scale" : "2x"
50 | },
51 | {
52 | "size" : "60x60",
53 | "idiom" : "iphone",
54 | "filename" : "Icon-App-60x60@3x.png",
55 | "scale" : "3x"
56 | },
57 | {
58 | "size" : "20x20",
59 | "idiom" : "ipad",
60 | "filename" : "Icon-App-20x20@1x.png",
61 | "scale" : "1x"
62 | },
63 | {
64 | "size" : "20x20",
65 | "idiom" : "ipad",
66 | "filename" : "Icon-App-20x20@2x.png",
67 | "scale" : "2x"
68 | },
69 | {
70 | "size" : "29x29",
71 | "idiom" : "ipad",
72 | "filename" : "Icon-App-29x29@1x.png",
73 | "scale" : "1x"
74 | },
75 | {
76 | "size" : "29x29",
77 | "idiom" : "ipad",
78 | "filename" : "Icon-App-29x29@2x.png",
79 | "scale" : "2x"
80 | },
81 | {
82 | "size" : "40x40",
83 | "idiom" : "ipad",
84 | "filename" : "Icon-App-40x40@1x.png",
85 | "scale" : "1x"
86 | },
87 | {
88 | "size" : "40x40",
89 | "idiom" : "ipad",
90 | "filename" : "Icon-App-40x40@2x.png",
91 | "scale" : "2x"
92 | },
93 | {
94 | "size" : "76x76",
95 | "idiom" : "ipad",
96 | "filename" : "Icon-App-76x76@1x.png",
97 | "scale" : "1x"
98 | },
99 | {
100 | "size" : "76x76",
101 | "idiom" : "ipad",
102 | "filename" : "Icon-App-76x76@2x.png",
103 | "scale" : "2x"
104 | },
105 | {
106 | "size" : "83.5x83.5",
107 | "idiom" : "ipad",
108 | "filename" : "Icon-App-83.5x83.5@2x.png",
109 | "scale" : "2x"
110 | },
111 | {
112 | "size" : "1024x1024",
113 | "idiom" : "ios-marketing",
114 | "filename" : "Icon-App-1024x1024@1x.png",
115 | "scale" : "1x"
116 | }
117 | ],
118 | "info" : {
119 | "version" : 1,
120 | "author" : "xcode"
121 | }
122 | }
123 |
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/firstfloorsoftware/flutter_sodium/73171341a43ebb9041b15c6fe43e620d0e281d93/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/firstfloorsoftware/flutter_sodium/73171341a43ebb9041b15c6fe43e620d0e281d93/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/firstfloorsoftware/flutter_sodium/73171341a43ebb9041b15c6fe43e620d0e281d93/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/firstfloorsoftware/flutter_sodium/73171341a43ebb9041b15c6fe43e620d0e281d93/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/firstfloorsoftware/flutter_sodium/73171341a43ebb9041b15c6fe43e620d0e281d93/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/firstfloorsoftware/flutter_sodium/73171341a43ebb9041b15c6fe43e620d0e281d93/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/firstfloorsoftware/flutter_sodium/73171341a43ebb9041b15c6fe43e620d0e281d93/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/firstfloorsoftware/flutter_sodium/73171341a43ebb9041b15c6fe43e620d0e281d93/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/firstfloorsoftware/flutter_sodium/73171341a43ebb9041b15c6fe43e620d0e281d93/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/firstfloorsoftware/flutter_sodium/73171341a43ebb9041b15c6fe43e620d0e281d93/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/firstfloorsoftware/flutter_sodium/73171341a43ebb9041b15c6fe43e620d0e281d93/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/firstfloorsoftware/flutter_sodium/73171341a43ebb9041b15c6fe43e620d0e281d93/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/firstfloorsoftware/flutter_sodium/73171341a43ebb9041b15c6fe43e620d0e281d93/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/firstfloorsoftware/flutter_sodium/73171341a43ebb9041b15c6fe43e620d0e281d93/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/firstfloorsoftware/flutter_sodium/73171341a43ebb9041b15c6fe43e620d0e281d93/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "LaunchImage.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "filename" : "LaunchImage@2x.png",
11 | "scale" : "2x"
12 | },
13 | {
14 | "idiom" : "universal",
15 | "filename" : "LaunchImage@3x.png",
16 | "scale" : "3x"
17 | }
18 | ],
19 | "info" : {
20 | "version" : 1,
21 | "author" : "xcode"
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/firstfloorsoftware/flutter_sodium/73171341a43ebb9041b15c6fe43e620d0e281d93/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/firstfloorsoftware/flutter_sodium/73171341a43ebb9041b15c6fe43e620d0e281d93/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/firstfloorsoftware/flutter_sodium/73171341a43ebb9041b15c6fe43e620d0e281d93/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md:
--------------------------------------------------------------------------------
1 | # Launch Screen Assets
2 |
3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory.
4 |
5 | You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images.
--------------------------------------------------------------------------------
/example/ios/Runner/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/example/ios/Runner/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/example/ios/Runner/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | flutter_sodium_example
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | $(FLUTTER_BUILD_NAME)
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | $(FLUTTER_BUILD_NUMBER)
23 | LSRequiresIPhoneOS
24 |
25 | UILaunchStoryboardName
26 | LaunchScreen
27 | UIMainStoryboardFile
28 | Main
29 | UISupportedInterfaceOrientations
30 |
31 | UIInterfaceOrientationPortrait
32 | UIInterfaceOrientationLandscapeLeft
33 | UIInterfaceOrientationLandscapeRight
34 |
35 | UISupportedInterfaceOrientations~ipad
36 |
37 | UIInterfaceOrientationPortrait
38 | UIInterfaceOrientationPortraitUpsideDown
39 | UIInterfaceOrientationLandscapeLeft
40 | UIInterfaceOrientationLandscapeRight
41 |
42 | UIViewControllerBasedStatusBarAppearance
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/example/ios/Runner/Runner-Bridging-Header.h:
--------------------------------------------------------------------------------
1 | #import "GeneratedPluginRegistrant.h"
--------------------------------------------------------------------------------
/example/lib/main.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:flutter_sodium/flutter_sodium.dart';
3 | import 'toc.dart';
4 | import 'topic_page.dart';
5 |
6 | void main() {
7 | Sodium.init();
8 |
9 | runApp(MyApp());
10 | }
11 |
12 | class MyApp extends StatelessWidget {
13 | @override
14 | Widget build(BuildContext context) {
15 | return MaterialApp(
16 | title: 'flutter_sodium',
17 | theme: ThemeData(
18 | primarySwatch: Colors.blue,
19 | ),
20 | home: HomePage(),
21 | );
22 | }
23 | }
24 |
25 | class HomePage extends StatelessWidget {
26 | @override
27 | Widget build(BuildContext context) {
28 | return Scaffold(
29 | appBar: AppBar(
30 | title: Text('flutter_sodium'),
31 | ),
32 | body: SafeArea(
33 | child: FutureBuilder(
34 | // build table of contents
35 | future: buildToc(context),
36 | builder: (BuildContext context,
37 | AsyncSnapshot> snapshot) {
38 | if (snapshot.connectionState == ConnectionState.done) {
39 | return snapshot.hasError
40 | ? Text("Build TOC failed\n\n${snapshot.error}")
41 | : ListView(children: [
42 | if (snapshot.hasData)
43 | for (var topic in snapshot.data!)
44 | if (topic is Section)
45 | ListTile(
46 | title: Text(topic.title,
47 | style: Theme.of(context)
48 | .textTheme
49 | .headline6))
50 | else
51 | ListTile(
52 | title: Text(topic.title),
53 | trailing: Icon(Icons.arrow_forward_ios,
54 | size: 12.0),
55 | onTap: () => Navigator.push(
56 | context,
57 | MaterialPageRoute(
58 | builder: (context) =>
59 | TopicPage(topic))))
60 | ]);
61 | }
62 |
63 | return Container();
64 | })));
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/example/lib/sample_widget.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'toc.dart';
3 |
4 | class SampleWidget extends StatelessWidget {
5 | final Sample sample;
6 | SampleWidget(this.sample);
7 |
8 | @override
9 | Widget build(BuildContext context) {
10 | return Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
11 | Padding(
12 | padding: EdgeInsets.symmetric(vertical: 16.0),
13 | child: Text(sample.title ?? '(no title)',
14 | style: Theme.of(context).textTheme.headline5)),
15 | if (sample.description != null && sample.description!.length > 0)
16 | Padding(
17 | padding: EdgeInsets.only(bottom: 16.0),
18 | child: Text(sample.description!),
19 | ),
20 | CodeBlock(sample.code),
21 | SampleRunner(sample)
22 | ]);
23 | }
24 | }
25 |
26 | class SampleRunner extends StatefulWidget {
27 | final Sample sample;
28 |
29 | SampleRunner(this.sample);
30 |
31 | @override
32 | State createState() => _SampleRunnerState();
33 | }
34 |
35 | class _SampleRunnerState extends State {
36 | Future? _sampleRun;
37 |
38 | void _runSample() {
39 | setState(() {
40 | _sampleRun = _runSampleHost();
41 | });
42 | }
43 |
44 | Future _runSampleHost() async {
45 | final out = StringBuffer();
46 |
47 | // run sync or async code sample
48 | if (widget.sample.funcAsync != null) {
49 | await widget.sample.funcAsync!((o) => out.writeln(o));
50 | } else if (widget.sample.func != null) {
51 | widget.sample.func!((o) => out.writeln(o));
52 | }
53 | return out.toString().trim();
54 | }
55 |
56 | @override
57 | Widget build(BuildContext context) {
58 | if (_sampleRun == null) {
59 | return Padding(
60 | padding: EdgeInsets.only(top: 16.0), child: RunButton(_runSample));
61 | }
62 |
63 | return FutureBuilder(
64 | future: _sampleRun,
65 | builder: (BuildContext context, AsyncSnapshot snapshot) =>
66 | Column(
67 | crossAxisAlignment: CrossAxisAlignment.start,
68 | children: [
69 | Padding(
70 | padding: EdgeInsets.symmetric(vertical: 16.0),
71 | child: RunButton(
72 | snapshot.connectionState == ConnectionState.done
73 | ? _runSample
74 | : null)),
75 | Padding(
76 | padding: EdgeInsets.only(bottom: 16.0),
77 | child: Text('Result',
78 | style: Theme.of(context).textTheme.headline6)),
79 | // display progress only for async code snippets
80 | if (widget.sample.funcAsync != null &&
81 | snapshot.connectionState != ConnectionState.done)
82 | LinearProgressIndicator(),
83 | AnimatedOpacity(
84 | opacity: snapshot.connectionState == ConnectionState.done
85 | ? 1
86 | : 0,
87 | duration: Duration(
88 | milliseconds:
89 | snapshot.connectionState == ConnectionState.done
90 | ? 150
91 | : 50),
92 | child: CodeBlock(
93 | snapshot.hasError
94 | ? snapshot.error.toString()
95 | : snapshot.data,
96 | color: snapshot.hasError
97 | ? Colors.red.shade200
98 | : Colors.green.shade200)),
99 | ]));
100 | }
101 | }
102 |
103 | class RunButton extends StatelessWidget {
104 | final VoidCallback? onPressed;
105 |
106 | RunButton(this.onPressed);
107 |
108 | @override
109 | Widget build(BuildContext context) {
110 | return ElevatedButton(child: Text('Run'), onPressed: onPressed);
111 | }
112 | }
113 |
114 | class CodeBlock extends StatelessWidget {
115 | final String? _code;
116 | final Color color;
117 |
118 | CodeBlock(this._code, {this.color = Colors.black12});
119 |
120 | @override
121 | Widget build(BuildContext context) {
122 | return Container(
123 | padding: EdgeInsets.all(10.0),
124 | color: color,
125 | child: Text(_code ?? '(code not found)',
126 | style: TextStyle(fontFamily: 'RobotoMono', fontSize: 12.0)));
127 | }
128 | }
129 |
--------------------------------------------------------------------------------
/example/lib/toc.dart:
--------------------------------------------------------------------------------
1 | import 'dart:convert';
2 | import 'package:flutter/material.dart';
3 | import 'samples.dart';
4 |
5 | typedef void SampleFunc(Function(Object) print);
6 | typedef Future SampleFuncAsync(Function(Object) print);
7 |
8 | class Section extends Topic {
9 | Section(String title) : super(title);
10 | }
11 |
12 | class Topic {
13 | final String title;
14 | final String? description;
15 | final String? url;
16 | final List? samples;
17 |
18 | Topic(this.title, {this.description, this.url, this.samples});
19 | }
20 |
21 | class Sample {
22 | final String name;
23 | final SampleFunc? func;
24 | final SampleFuncAsync? funcAsync;
25 | String? title;
26 | String? description;
27 | String? code;
28 |
29 | Sample(this.name, {this.func, this.funcAsync});
30 | }
31 |
32 | Future> buildToc(BuildContext context) async {
33 | final samples = Samples();
34 |
35 | final toc = [
36 | Section('Common'),
37 | Topic('APIs',
38 | description:
39 | 'The flutter_sodium library contains two sets of APIs, a core API and a high-level API. The core API maps native libsodium functions 1:1 to Dart equivalents. The high-level API provides Dart-friendly, opinionated access to libsodium.',
40 | samples: [
41 | Sample('api1', func: samples.api1),
42 | Sample('api2', func: samples.api2)
43 | ]),
44 | Topic('Random data',
45 | description:
46 | 'Provides a set of functions to generate unpredictable data, suitable for creating secret keys.',
47 | url: 'https://libsodium.gitbook.io/doc/generating_random_data/',
48 | samples: [
49 | Sample('random1', func: samples.random1),
50 | Sample('random2', func: samples.random2),
51 | Sample('random3', func: samples.random3)
52 | ]),
53 | Topic('Encoding',
54 | description: 'Encode byte sequence to string and vice versa.',
55 | url: 'https://libsodium.gitbook.io/doc/helpers',
56 | samples: [
57 | Sample('encoding1', func: samples.encoding1),
58 | Sample('encoding2', func: samples.encoding2)
59 | ]),
60 | Topic('Padding',
61 | description: 'Append padding data',
62 | url: 'https://libsodium.gitbook.io/doc/padding',
63 | samples: [Sample('padding1', func: samples.padding1)]),
64 | Topic('About',
65 | description: 'Provides libsodium version, runtime and algorithm info.',
66 | url: 'https://libsodium.gitbook.io/doc/',
67 | samples: [
68 | Sample('about1', func: samples.about1),
69 | Sample('about2', func: samples.about2),
70 | Sample('about3', func: samples.about3)
71 | ]),
72 | Section('Secret-key cryptography'),
73 | Topic('Authenticated encryption',
74 | description: 'Secret-key encryption and verification',
75 | url:
76 | 'https://libsodium.gitbook.io/doc/secret-key_cryptography/secretbox',
77 | samples: [
78 | Sample('secret1', func: samples.secret1),
79 | Sample('secret2', func: samples.secret2)
80 | ]),
81 | Topic('Authentication',
82 | description:
83 | 'Computes an authentication tag for a message and a secret key, and provides a way to verify that a given tag is valid for a given message and a key.',
84 | url:
85 | 'https://libsodium.gitbook.io/doc/secret-key_cryptography/secret-key_authentication',
86 | samples: [
87 | Sample('auth1', func: samples.auth1),
88 | ]),
89 | Topic('Original ChaCha20-Poly1305',
90 | description: 'Authenticated Encryption with Additional Data.',
91 | url:
92 | 'https://libsodium.gitbook.io/doc/secret-key_cryptography/aead/chacha20-poly1305/original_chacha20-poly1305_construction',
93 | samples: [
94 | Sample('chacha1', func: samples.chacha1),
95 | Sample('chacha2', func: samples.chacha2)
96 | ]),
97 | Topic('IETF ChaCha20-Poly1305',
98 | description: 'Authenticated Encryption with Additional Data',
99 | url:
100 | 'https://libsodium.gitbook.io/doc/secret-key_cryptography/aead/chacha20-poly1305/ietf_chacha20-poly1305_construction',
101 | samples: [
102 | Sample('chachaietf1', func: samples.chachaietf1),
103 | Sample('chachaietf2', func: samples.chachaietf2)
104 | ]),
105 | Topic('XChaCha20-Poly1305',
106 | description: 'Authenticated Encryption with Additional Data.',
107 | url:
108 | 'https://libsodium.gitbook.io/doc/secret-key_cryptography/aead/chacha20-poly1305/xchacha20-poly1305_construction',
109 | samples: [
110 | Sample('xchachaietf1', func: samples.xchachaietf1),
111 | Sample('xchachaietf2', func: samples.xchachaietf2)
112 | ]),
113 | Section('Public-key cryptography'),
114 | Topic('Authenticated encryption',
115 | description: 'Public-key authenticated encryption',
116 | url:
117 | 'https://libsodium.gitbook.io/doc/public-key_cryptography/authenticated_encryption',
118 | samples: [
119 | Sample('box1', func: samples.box1),
120 | Sample('box2', func: samples.box2),
121 | Sample('box3', func: samples.box3),
122 | Sample('box4', func: samples.box4)
123 | ]),
124 | Topic('Public-key signatures',
125 | description:
126 | 'Computes a signature for a message using a secret key, and provides verification using a public key.',
127 | url:
128 | 'https://libsodium.gitbook.io/doc/public-key_cryptography/public-key_signatures',
129 | samples: [
130 | Sample('sign1', func: samples.sign1),
131 | Sample('sign2', func: samples.sign2),
132 | Sample('sign3', funcAsync: samples.sign3),
133 | Sample('sign4', func: samples.sign4)
134 | ]),
135 | Topic('Sealed boxes',
136 | description:
137 | 'Anonymously send encrypted messages to a recipient given its public key.',
138 | url: 'https://libsodium.gitbook.io/doc/public-key_cryptography/sealed_boxes',
139 | samples: [Sample('box5', func: samples.box5)]),
140 | Section('Hashing'),
141 | Topic('Generic hashing',
142 | description:
143 | 'Computes a fixed-length fingerprint for an arbitrary long message using the BLAKE2b algorithm.',
144 | url: 'https://libsodium.gitbook.io/doc/hashing/generic_hashing',
145 | samples: [
146 | Sample('generic1', func: samples.generic1),
147 | Sample('generic2', func: samples.generic2),
148 | Sample('generic3', funcAsync: samples.generic3),
149 | Sample('generic4', funcAsync: samples.generic4)
150 | ]),
151 | Topic('Short-input hashing',
152 | description: 'Computes short hashes using the SipHash-2-4 algorithm.',
153 | url: 'https://libsodium.gitbook.io/doc/hashing/short-input_hashing',
154 | samples: [Sample('shorthash1', func: samples.shorthash1)]),
155 | Topic('Password hashing',
156 | description:
157 | 'Provides an Argon2 password hashing scheme implementation.',
158 | url:
159 | 'https://libsodium.gitbook.io/doc/password_hashing/the_argon2i_function',
160 | samples: [
161 | Sample('pwhash1', func: samples.pwhash1),
162 | Sample('pwhash2', func: samples.pwhash2),
163 | Sample('pwhash3', funcAsync: samples.pwhash3),
164 | ]),
165 | Section('Key functions'),
166 | Topic('Key derivation',
167 | description: 'Derive secret subkeys from a single master key.',
168 | url: 'https://libsodium.gitbook.io/doc/key_derivation/',
169 | samples: [Sample('kdf1', func: samples.kdf1)]),
170 | Topic('Key exchange',
171 | description: 'Securely compute a set of shared keys.',
172 | url: 'https://libsodium.gitbook.io/doc/key_exchange/',
173 | samples: [Sample('kx1', func: samples.kx1)]),
174 | Section('Advanced'),
175 | Topic('SHA-2',
176 | description: 'SHA-512 hash functions',
177 | url: 'https://libsodium.gitbook.io/doc/advanced/sha-2_hash_function',
178 | samples: [Sample('hash1', func: samples.hash1)]),
179 | Topic('Diffie-Hellman',
180 | description: 'Perform scalar multiplication of elliptic curve points',
181 | url: 'https://libsodium.gitbook.io/doc/advanced/scalar_multiplication',
182 | samples: [
183 | Sample('scalarmult1', funcAsync: samples.scalarmult1)
184 | ]),
185 | Topic('One-time authentication',
186 | description: 'Secret-key single-message authentication using Poly1305',
187 | url: 'https://libsodium.gitbook.io/doc/advanced/poly1305',
188 | samples: [
189 | Sample('onetime1', func: samples.onetime1),
190 | Sample('onetime2', funcAsync: samples.onetime2)
191 | ]),
192 | Topic('Stream ciphers',
193 | description: 'Generate pseudo-random data from a key',
194 | url: 'https://libsodium.gitbook.io/doc/advanced/stream_ciphers',
195 | samples: [Sample('stream1', func: samples.stream1)]),
196 | Topic('Ed25519 To Curve25519',
197 | description:
198 | 'Ed25519 keys can be converted to X25519 keys, so that the same key pair can be used both for authenticated encryption (crypto_box) and for signatures (crypto_sign).',
199 | url: 'https://download.libsodium.org/doc/advanced/ed25519-curve25519',
200 | samples: [Sample('sign5', func: samples.sign5)])
201 | ];
202 |
203 | // load asset samples.dart for code snippets
204 | final src =
205 | await DefaultAssetBundle.of(context).loadString('lib/samples.dart');
206 |
207 | // iterate all samples in the toc, and parse title, description and code snippet
208 | for (var topic in toc) {
209 | if (topic.samples != null) {
210 | for (var sample in topic.samples!) {
211 | final beginTag = '// BEGIN ${sample.name}:';
212 | final begin = src.indexOf(beginTag);
213 | assert(begin != -1);
214 |
215 | // parse title
216 | final beginTitle = begin + beginTag.length;
217 | final endTitle = src.indexOf(':', beginTitle);
218 | assert(endTitle != -1);
219 | sample.title = src.substring(beginTitle, endTitle).trim();
220 |
221 | // parse description
222 | final endDescription = src.indexOf('\n', endTitle);
223 | assert(endDescription != -1);
224 | sample.description = src.substring(endTitle + 1, endDescription).trim();
225 |
226 | final end = src.indexOf('// END ${sample.name}', endDescription);
227 | assert(end != -1);
228 |
229 | sample.code = _formatCode(src.substring(endDescription, end));
230 | }
231 | }
232 | }
233 |
234 | return toc;
235 | }
236 |
237 | String _formatCode(String code) {
238 | final result = StringBuffer();
239 | final lines = LineSplitter.split(code).toList();
240 | int indent = -1;
241 | for (var i = 0; i < lines.length; i++) {
242 | String line = lines[i];
243 | // skip empty first and last lines
244 | if (line.trim().length == 0 && (i == 0 || i == lines.length - 1)) {
245 | continue;
246 | }
247 | // determine indent
248 | if (indent == -1) {
249 | for (indent = 0; indent < line.length; indent++) {
250 | if (line[indent] != ' ') {
251 | break;
252 | }
253 | }
254 | }
255 |
256 | // remove indent from line
257 | if (line.startsWith(' ' * indent)) {
258 | line = line.substring(indent);
259 | }
260 |
261 | if (result.isNotEmpty) {
262 | result.writeln();
263 | }
264 | result.write(line);
265 | }
266 | return result.toString();
267 | }
268 |
--------------------------------------------------------------------------------
/example/lib/topic_page.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:flutter_sodium_example/sample_widget.dart';
3 | import 'package:url_launcher/url_launcher.dart';
4 | import 'toc.dart';
5 |
6 | class TopicPage extends StatelessWidget {
7 | final Topic topic;
8 |
9 | TopicPage(this.topic);
10 |
11 | @override
12 | Widget build(BuildContext context) {
13 | return Scaffold(
14 | appBar: AppBar(
15 | title: Text(topic.title),
16 | ),
17 | body: SafeArea(
18 | child: SingleChildScrollView(
19 | child: Container(
20 | padding: EdgeInsets.all(15.0),
21 | child: Column(
22 | crossAxisAlignment: CrossAxisAlignment.start,
23 | children: [
24 | // description
25 | if (topic.description != null)
26 | Padding(
27 | padding: EdgeInsets.only(bottom: 16.0),
28 | child: Text(topic.description!)),
29 | // more info button
30 | if (topic.url != null)
31 | Padding(
32 | padding: EdgeInsets.only(bottom: 16.0),
33 | child: InkWell(
34 | child: Text(
35 | 'More information',
36 | style: TextStyle(
37 | color: Theme.of(context).accentColor),
38 | ),
39 | onTap: () => launch(topic.url!)),
40 | ),
41 | // 0..n samples
42 | if (topic.samples != null)
43 | for (var sample in topic.samples!)
44 | Padding(
45 | padding: EdgeInsets.only(bottom: 16.0),
46 | child: SampleWidget(sample))
47 | ],
48 | )))));
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/example/macos/Podfile:
--------------------------------------------------------------------------------
1 | platform :osx, '10.11'
2 |
3 | # CocoaPods analytics sends network stats synchronously affecting flutter build latency.
4 | ENV['COCOAPODS_DISABLE_STATS'] = 'true'
5 |
6 | project 'Runner', {
7 | 'Debug' => :debug,
8 | 'Profile' => :release,
9 | 'Release' => :release,
10 | }
11 |
12 | def parse_KV_file(file, separator='=')
13 | file_abs_path = File.expand_path(file)
14 | if !File.exists? file_abs_path
15 | return [];
16 | end
17 | pods_ary = []
18 | skip_line_start_symbols = ["#", "/"]
19 | File.foreach(file_abs_path) { |line|
20 | next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ }
21 | plugin = line.split(pattern=separator)
22 | if plugin.length == 2
23 | podname = plugin[0].strip()
24 | path = plugin[1].strip()
25 | podpath = File.expand_path("#{path}", file_abs_path)
26 | pods_ary.push({:name => podname, :path => podpath});
27 | else
28 | puts "Invalid plugin specification: #{line}"
29 | end
30 | }
31 | return pods_ary
32 | end
33 |
34 | def pubspec_supports_macos(file)
35 | file_abs_path = File.expand_path(file)
36 | if !File.exists? file_abs_path
37 | return false;
38 | end
39 | File.foreach(file_abs_path) { |line|
40 | return true if line =~ /^\s*macos:/
41 | }
42 | return false
43 | end
44 |
45 | target 'Runner' do
46 | use_frameworks!
47 | use_modular_headers!
48 |
49 | # Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
50 | # referring to absolute paths on developers' machines.
51 | ephemeral_dir = File.join('Flutter', 'ephemeral')
52 | symlink_dir = File.join(ephemeral_dir, '.symlinks')
53 | symlink_plugins_dir = File.join(symlink_dir, 'plugins')
54 | system("rm -rf #{symlink_dir}")
55 | system("mkdir -p #{symlink_plugins_dir}")
56 |
57 | # Flutter Pods
58 | generated_xcconfig = parse_KV_file(File.join(ephemeral_dir, 'Flutter-Generated.xcconfig'))
59 | if generated_xcconfig.empty?
60 | puts "Flutter-Generated.xcconfig must exist. If you're running pod install manually, make sure flutter packages get is executed first."
61 | end
62 | generated_xcconfig.map { |p|
63 | if p[:name] == 'FLUTTER_FRAMEWORK_DIR'
64 | symlink = File.join(symlink_dir, 'flutter')
65 | File.symlink(File.dirname(p[:path]), symlink)
66 | pod 'FlutterMacOS', :path => File.join(symlink, File.basename(p[:path]))
67 | end
68 | }
69 |
70 | # Plugin Pods
71 | plugin_pods = parse_KV_file('../.flutter-plugins')
72 | plugin_pods.map { |p|
73 | symlink = File.join(symlink_plugins_dir, p[:name])
74 | File.symlink(p[:path], symlink)
75 | if pubspec_supports_macos(File.join(symlink, 'pubspec.yaml'))
76 | pod p[:name], :path => File.join(symlink, 'macos')
77 | end
78 | }
79 | end
80 |
81 | # Prevent Cocoapods from embedding a second Flutter framework and causing an error with the new Xcode build system.
82 | install! 'cocoapods', :disable_input_output_paths => true
83 |
--------------------------------------------------------------------------------
/example/pubspec.yaml:
--------------------------------------------------------------------------------
1 | name: flutter_sodium_example
2 | version: 2.0.0
3 | description: Demonstrates how to use the flutter_sodium plugin.
4 | publish_to: 'none'
5 |
6 | environment:
7 | sdk: ">=2.12.0 <3.0.0"
8 |
9 | dependencies:
10 | flutter:
11 | sdk: flutter
12 | url_launcher: ^6.0.2
13 |
14 | dev_dependencies:
15 | flutter_test:
16 | sdk: flutter
17 |
18 | flutter_sodium:
19 | path: ../
20 |
21 | flutter:
22 | uses-material-design: true
23 | assets:
24 | - lib/samples.dart
25 | fonts:
26 | - family: RobotoMono
27 | fonts:
28 | - asset: assets/fonts/RobotoMono-Regular.ttf
--------------------------------------------------------------------------------
/example/test/widget_test.dart:
--------------------------------------------------------------------------------
1 | // This is a basic Flutter widget test.
2 | //
3 | // To perform an interaction with a widget in your test, use the WidgetTester
4 | // utility that Flutter provides. For example, you can send tap and scroll
5 | // gestures. You can also use WidgetTester to find child widgets in the widget
6 | // tree, read text, and verify that the values of widget properties are correct.
7 |
8 | void main() {}
9 |
--------------------------------------------------------------------------------
/flutter_sodium.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/ios/.gitignore:
--------------------------------------------------------------------------------
1 | .idea/
2 | .vagrant/
3 | .sconsign.dblite
4 | .svn/
5 |
6 | .DS_Store
7 | *.swp
8 | profile
9 |
10 | DerivedData/
11 | build/
12 | GeneratedPluginRegistrant.h
13 | GeneratedPluginRegistrant.m
14 |
15 | .generated/
16 |
17 | *.pbxuser
18 | *.mode1v3
19 | *.mode2v3
20 | *.perspectivev3
21 |
22 | !default.pbxuser
23 | !default.mode1v3
24 | !default.mode2v3
25 | !default.perspectivev3
26 |
27 | xcuserdata
28 |
29 | *.moved-aside
30 |
31 | *.pyc
32 | *sync/
33 | Icon?
34 | .tags*
35 |
36 | /Flutter/Generated.xcconfig
37 | /Flutter/flutter_export_environment.sh
--------------------------------------------------------------------------------
/ios/Classes/FlutterSodiumPlugin.h:
--------------------------------------------------------------------------------
1 | #import
2 |
3 | @interface FlutterSodiumPlugin : NSObject
4 | @end
--------------------------------------------------------------------------------
/ios/Classes/FlutterSodiumPlugin.m:
--------------------------------------------------------------------------------
1 | #import "FlutterSodiumPlugin.h"
2 |
3 | @implementation FlutterSodiumPlugin
4 | + (void)registerWithRegistrar:(NSObject*)registrar {
5 | }
6 | @end
--------------------------------------------------------------------------------
/ios/flutter_sodium.podspec:
--------------------------------------------------------------------------------
1 | #
2 | # To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html.
3 | # Run `pod lib lint flutter_sodium.podspec' to validate before publishing.
4 | #
5 | Pod::Spec.new do |s|
6 | s.name = 'flutter_sodium'
7 | s.version = '0.0.1'
8 | s.summary = 'A new flutter plugin project.'
9 | s.description = <<-DESC
10 | A new flutter plugin project.
11 | DESC
12 | s.homepage = 'http://example.com'
13 | s.license = { :file => '../LICENSE' }
14 | s.author = { 'Your Company' => 'email@example.com' }
15 | s.source = { :path => '.' }
16 | s.public_header_files = 'Classes**/*.h'
17 | s.source_files = 'Classes/**/*'
18 | s.vendored_libraries = "**/*.a"
19 | s.dependency 'Flutter'
20 | s.platform = :ios, '8.0'
21 |
22 | # Flutter.framework does not contain a i386 slice. Only x86_64 simulators are supported.
23 | s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'VALID_ARCHS[sdk=iphonesimulator*]' => 'x86_64' }
24 | s.swift_version = '5.0'
25 | s.xcconfig = { 'OTHER_LDFLAGS' => '-force_load "${PODS_ROOT}/../.symlinks/plugins/flutter_sodium/ios/libsodium.a"'}
26 | end
27 |
--------------------------------------------------------------------------------
/ios/libsodium.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/firstfloorsoftware/flutter_sodium/73171341a43ebb9041b15c6fe43e620d0e281d93/ios/libsodium.a
--------------------------------------------------------------------------------
/lib/flutter_sodium.dart:
--------------------------------------------------------------------------------
1 | library flutter_sodium;
2 |
3 | export 'src/cha_cha20_poly1305_ietf.dart';
4 | export 'src/cha_cha20_poly1305.dart';
5 | export 'src/crypto_auth.dart';
6 | export 'src/crypto_box.dart';
7 | export 'src/crypto_sign.dart';
8 | export 'src/crypto_stream.dart';
9 | export 'src/detached_cipher.dart';
10 | export 'src/generic_hash.dart';
11 | export 'src/hash.dart';
12 | export 'src/key_derivation.dart';
13 | export 'src/key_exchange.dart';
14 | export 'src/key_pair.dart';
15 | export 'src/onetime_auth.dart';
16 | export 'src/password_hash.dart';
17 | export 'src/random_bytes.dart';
18 | export 'src/scalar_mult.dart';
19 | export 'src/secret_box.dart';
20 | export 'src/sealed_box.dart';
21 | export 'src/session_keys.dart';
22 | export 'src/short_hash.dart';
23 | export 'src/sodium.dart';
24 | export 'src/sodium_exception.dart';
25 | export 'src/x_cha_cha20_poly1305_ietf.dart';
26 |
--------------------------------------------------------------------------------
/lib/src/bindings/crypto_aead_bindings.dart:
--------------------------------------------------------------------------------
1 | import 'dart:ffi';
2 | import 'libsodium.dart';
3 |
4 | // ignore_for_file: non_constant_identifier_names
5 |
6 | class CryptoAeadBindings {
7 | final String name;
8 | final int Function() keybytes;
9 | final int Function() nsecbytes;
10 | final int Function() npubbytes;
11 | final int Function() abytes;
12 | final int Function() messagebytes_max;
13 |
14 | final int Function(
15 | Pointer c,
16 | Pointer clen_p,
17 | Pointer m,
18 | int mlen,
19 | Pointer ad,
20 | int adlen,
21 | Pointer nsec,
22 | Pointer npub,
23 | Pointer k) encrypt;
24 |
25 | final int Function(
26 | Pointer m,
27 | Pointer mlen_p,
28 | Pointer nsec,
29 | Pointer c,
30 | int clen,
31 | Pointer ad,
32 | int adlen,
33 | Pointer npub,
34 | Pointer k) decrypt;
35 |
36 | final int Function(
37 | Pointer c,
38 | Pointer mac,
39 | Pointer maclen_p,
40 | Pointer m,
41 | int mlen,
42 | Pointer ad,
43 | int adlen,
44 | Pointer nsec,
45 | Pointer npub,
46 | Pointer k) encrypt_detached;
47 |
48 | final int Function(
49 | Pointer m,
50 | Pointer nsec,
51 | Pointer c,
52 | int clen,
53 | Pointer mac,
54 | Pointer ad,
55 | int adlen,
56 | Pointer npub,
57 | Pointer k) decrypt_detached;
58 |
59 | final void Function(Pointer k) keygen;
60 |
61 | CryptoAeadBindings(this.name)
62 | : keybytes = libsodium.lookupSizet('${name}_keybytes'),
63 | nsecbytes = libsodium.lookupSizet('${name}_nsecbytes'),
64 | npubbytes = libsodium.lookupSizet('${name}_npubbytes'),
65 | abytes = libsodium.lookupSizet('${name}_abytes'),
66 | messagebytes_max = libsodium.lookupSizet('${name}_messagebytes_max'),
67 | encrypt = libsodium
68 | .lookup<
69 | NativeFunction<
70 | Int32 Function(
71 | Pointer,
72 | Pointer,
73 | Pointer,
74 | Uint64,
75 | Pointer,
76 | Uint64,
77 | Pointer,
78 | Pointer,
79 | Pointer)>>('${name}_encrypt')
80 | .asFunction(),
81 | decrypt = libsodium
82 | .lookup<
83 | NativeFunction<
84 | Int32 Function(
85 | Pointer,
86 | Pointer,
87 | Pointer,
88 | Pointer,
89 | Uint64,
90 | Pointer,
91 | Uint64,
92 | Pointer,
93 | Pointer)>>('${name}_decrypt')
94 | .asFunction(),
95 | encrypt_detached = libsodium
96 | .lookup<
97 | NativeFunction<
98 | Int32 Function(
99 | Pointer,
100 | Pointer,
101 | Pointer,
102 | Pointer,
103 | Uint64,
104 | Pointer,
105 | Uint64,
106 | Pointer,
107 | Pointer,
108 | Pointer)>>('${name}_encrypt_detached')
109 | .asFunction(),
110 | decrypt_detached = libsodium
111 | .lookup<
112 | NativeFunction<
113 | Int32 Function(
114 | Pointer,
115 | Pointer,
116 | Pointer,
117 | Uint64,
118 | Pointer,
119 | Pointer,
120 | Uint64,
121 | Pointer,
122 | Pointer)>>('${name}_decrypt_detached')
123 | .asFunction(),
124 | keygen = libsodium
125 | .lookup)>>(
126 | '${name}_keygen')
127 | .asFunction();
128 | }
129 |
--------------------------------------------------------------------------------
/lib/src/bindings/crypto_auth_bindings.dart:
--------------------------------------------------------------------------------
1 | import 'dart:ffi';
2 | import 'package:ffi/ffi.dart';
3 | import 'libsodium.dart';
4 |
5 | // ignore_for_file: non_constant_identifier_names
6 |
7 | class CryptoAuthBindings {
8 | final int Function() crypto_auth_bytes =
9 | libsodium.lookupSizet('crypto_auth_bytes');
10 |
11 | final int Function() crypto_auth_keybytes =
12 | libsodium.lookupSizet('crypto_auth_keybytes');
13 |
14 | final Pointer Function() crypto_auth_primitive = libsodium
15 | .lookup Function()>>('crypto_auth_primitive')
16 | .asFunction();
17 |
18 | final int Function(
19 | Pointer out, Pointer i, int inlen, Pointer k)
20 | crypto_auth = libsodium
21 | .lookup<
22 | NativeFunction<
23 | Int32 Function(Pointer, Pointer, Uint64,
24 | Pointer)>>('crypto_auth')
25 | .asFunction();
26 |
27 | final int Function(
28 | Pointer h, Pointer i, int inlen, Pointer k)
29 | crypto_auth_verify = libsodium
30 | .lookup<
31 | NativeFunction<
32 | Int32 Function(Pointer, Pointer, Uint64,
33 | Pointer)>>('crypto_auth_verify')
34 | .asFunction();
35 |
36 | final void Function(Pointer k) crypto_auth_keygen = libsodium
37 | .lookup)>>(
38 | 'crypto_auth_keygen')
39 | .asFunction();
40 | }
41 |
--------------------------------------------------------------------------------
/lib/src/bindings/crypto_box_bindings.dart:
--------------------------------------------------------------------------------
1 | import 'dart:ffi';
2 | import 'package:ffi/ffi.dart';
3 | import 'libsodium.dart';
4 |
5 | // ignore_for_file: non_constant_identifier_names
6 |
7 | class CryptoBoxBindings {
8 | final int Function() crypto_box_seedbytes =
9 | libsodium.lookupSizet('crypto_box_seedbytes');
10 |
11 | final int Function() crypto_box_publickeybytes =
12 | libsodium.lookupSizet('crypto_box_publickeybytes');
13 |
14 | final int Function() crypto_box_secretkeybytes =
15 | libsodium.lookupSizet('crypto_box_secretkeybytes');
16 |
17 | final int Function() crypto_box_noncebytes =
18 | libsodium.lookupSizet('crypto_box_noncebytes');
19 |
20 | final int Function() crypto_box_macbytes =
21 | libsodium.lookupSizet('crypto_box_macbytes');
22 |
23 | final int Function() crypto_box_messagebytes_max =
24 | libsodium.lookupSizet('crypto_box_messagebytes_max');
25 |
26 | final int Function() crypto_box_sealbytes =
27 | libsodium.lookupSizet('crypto_box_sealbytes');
28 |
29 | final int Function() crypto_box_beforenmbytes =
30 | libsodium.lookupSizet('crypto_box_beforenmbytes');
31 |
32 | final Pointer Function() crypto_box_primitive = libsodium
33 | .lookup Function()>>('crypto_box_primitive')
34 | .asFunction();
35 |
36 | final int Function(Pointer pk, Pointer sk, Pointer seed)
37 | crypto_box_seed_keypair = libsodium
38 | .lookup<
39 | NativeFunction<
40 | Int32 Function(Pointer, Pointer,
41 | Pointer)>>('crypto_box_seed_keypair')
42 | .asFunction();
43 |
44 | final int Function(
45 | Pointer pk,
46 | Pointer
47 | sk) crypto_box_keypair = libsodium
48 | .lookup, Pointer)>>(
49 | 'crypto_box_keypair')
50 | .asFunction();
51 |
52 | final int Function(Pointer c, Pointer m, int mlen,
53 | Pointer n, Pointer pk, Pointer sk)
54 | crypto_box_easy = libsodium
55 | .lookup<
56 | NativeFunction<
57 | Int32 Function(
58 | Pointer,
59 | Pointer,
60 | Uint64,
61 | Pointer,
62 | Pointer,
63 | Pointer)>>('crypto_box_easy')
64 | .asFunction();
65 |
66 | final int Function(Pointer m, Pointer c, int clen,
67 | Pointer n, Pointer pk, Pointer sk)
68 | crypto_box_open_easy = libsodium
69 | .lookup<
70 | NativeFunction<
71 | Int32 Function(
72 | Pointer,
73 | Pointer,
74 | Uint64,
75 | Pointer,
76 | Pointer,
77 | Pointer)>>('crypto_box_open_easy')
78 | .asFunction();
79 |
80 | final int Function(Pointer c, Pointer mac, Pointer m,
81 | int mlen, Pointer n, Pointer pk, Pointer sk)
82 | crypto_box_detached = libsodium
83 | .lookup<
84 | NativeFunction<
85 | Int32 Function(
86 | Pointer,
87 | Pointer,
88 | Pointer,
89 | Uint64,
90 | Pointer,
91 | Pointer,
92 | Pointer)>>('crypto_box_detached')
93 | .asFunction();
94 |
95 | final int Function(Pointer m, Pointer c, Pointer mac,
96 | int clen, Pointer n, Pointer pk, Pointer sk)
97 | crypto_box_open_detached = libsodium
98 | .lookup<
99 | NativeFunction<
100 | Int32 Function(
101 | Pointer,
102 | Pointer,
103 | Pointer,
104 | Uint64,
105 | Pointer,
106 | Pointer,
107 | Pointer)>>('crypto_box_open_detached')
108 | .asFunction();
109 |
110 | final int Function(
111 | Pointer c, Pointer m, int mlen, Pointer pk)
112 | crypto_box_seal = libsodium
113 | .lookup<
114 | NativeFunction<
115 | Int32 Function(Pointer, Pointer, Uint64,
116 | Pointer)>>('crypto_box_seal')
117 | .asFunction();
118 |
119 | final int Function(Pointer m, Pointer c, int clen,
120 | Pointer pk, Pointer sk) crypto_box_seal_open =
121 | libsodium
122 | .lookup<
123 | NativeFunction<
124 | Int32 Function(Pointer, Pointer, Uint64,
125 | Pointer, Pointer)>>('crypto_box_seal_open')
126 | .asFunction();
127 |
128 | final int Function(Pointer k, Pointer pk, Pointer sk)
129 | crypto_box_beforenm = libsodium
130 | .lookup<
131 | NativeFunction<
132 | Int32 Function(Pointer, Pointer,
133 | Pointer)>>('crypto_box_beforenm')
134 | .asFunction();
135 |
136 | final int Function(Pointer c, Pointer m, int mlen,
137 | Pointer n, Pointer k) crypto_box_easy_afternm =
138 | libsodium
139 | .lookup<
140 | NativeFunction<
141 | Int32 Function(
142 | Pointer,
143 | Pointer,
144 | Uint64,
145 | Pointer,
146 | Pointer)>>('crypto_box_easy_afternm')
147 | .asFunction();
148 |
149 | final int Function(Pointer m, Pointer c, int clen,
150 | Pointer n, Pointer k) crypto_box_open_easy_afternm =
151 | libsodium
152 | .lookup<
153 | NativeFunction<
154 | Int32 Function(
155 | Pointer,
156 | Pointer,
157 | Uint64,
158 | Pointer,
159 | Pointer)>>('crypto_box_open_easy_afternm')
160 | .asFunction();
161 |
162 | final int Function(Pointer c, Pointer mac, Pointer m,
163 | int mlen, Pointer n, Pointer k)
164 | crypto_box_detached_afternm = libsodium
165 | .lookup<
166 | NativeFunction<
167 | Int32 Function(
168 | Pointer,
169 | Pointer,
170 | Pointer,
171 | Uint64,
172 | Pointer,
173 | Pointer)>>('crypto_box_detached_afternm')
174 | .asFunction();
175 |
176 | final int Function(Pointer m, Pointer c, Pointer mac,
177 | int clen, Pointer n, Pointer k)
178 | crypto_box_open_detached_afternm = libsodium
179 | .lookup<
180 | NativeFunction<
181 | Int32 Function(
182 | Pointer,
183 | Pointer,
184 | Pointer,
185 | Uint64,
186 | Pointer,
187 | Pointer)>>('crypto_box_open_detached_afternm')
188 | .asFunction();
189 | }
190 |
--------------------------------------------------------------------------------
/lib/src/bindings/crypto_core_bindings.dart:
--------------------------------------------------------------------------------
1 | import 'dart:ffi';
2 | import 'libsodium.dart';
3 |
4 | // ignore_for_file: non_constant_identifier_names
5 |
6 | class CryptoCoreBindings {
7 | final int Function() crypto_core_hchacha20_outputbytes =
8 | libsodium.lookupSizet('crypto_core_hchacha20_outputbytes');
9 |
10 | final int Function() crypto_core_hchacha20_inputbytes =
11 | libsodium.lookupSizet('crypto_core_hchacha20_inputbytes');
12 |
13 | final int Function() crypto_core_hchacha20_keybytes =
14 | libsodium.lookupSizet('crypto_core_hchacha20_keybytes');
15 |
16 | final int Function() crypto_core_hchacha20_constbytes =
17 | libsodium.lookupSizet('crypto_core_hchacha20_constbytes');
18 |
19 | final int Function(Pointer out, Pointer in_, Pointer k,
20 | Pointer c) crypto_core_hchacha20 =
21 | libsodium
22 | .lookup<
23 | NativeFunction<
24 | Int32 Function(Pointer, Pointer, Pointer,
25 | Pointer)>>('crypto_core_hchacha20')
26 | .asFunction();
27 |
28 | final int Function() crypto_core_hsalsa20_outputbytes =
29 | libsodium.lookupSizet('crypto_core_hsalsa20_outputbytes');
30 |
31 | final int Function() crypto_core_hsalsa20_inputbytes =
32 | libsodium.lookupSizet('crypto_core_hsalsa20_inputbytes');
33 |
34 | final int Function() crypto_core_hsalsa20_keybytes =
35 | libsodium.lookupSizet('crypto_core_hsalsa20_keybytes');
36 |
37 | final int Function() crypto_core_hsalsa20_constbytes =
38 | libsodium.lookupSizet('crypto_core_hsalsa20_constbytes');
39 |
40 | final int Function(Pointer out, Pointer in_, Pointer k,
41 | Pointer c) crypto_core_hsalsa20 =
42 | libsodium
43 | .lookup<
44 | NativeFunction<
45 | Int32 Function(Pointer, Pointer, Pointer,
46 | Pointer)>>('crypto_core_hsalsa20')
47 | .asFunction();
48 | }
49 |
--------------------------------------------------------------------------------
/lib/src/bindings/crypto_generichash_bindings.dart:
--------------------------------------------------------------------------------
1 | import 'dart:ffi';
2 | import 'package:ffi/ffi.dart';
3 | import 'libsodium.dart';
4 |
5 | // ignore_for_file: non_constant_identifier_names
6 |
7 | class CryptoGenerichashBindings {
8 | final int Function() crypto_generichash_bytes_min =
9 | libsodium.lookupSizet('crypto_generichash_bytes_min');
10 |
11 | final int Function() crypto_generichash_bytes_max =
12 | libsodium.lookupSizet('crypto_generichash_bytes_max');
13 |
14 | final int Function() crypto_generichash_bytes =
15 | libsodium.lookupSizet('crypto_generichash_bytes');
16 |
17 | final int Function() crypto_generichash_keybytes_min =
18 | libsodium.lookupSizet('crypto_generichash_keybytes_min');
19 |
20 | final int Function() crypto_generichash_keybytes_max =
21 | libsodium.lookupSizet('crypto_generichash_keybytes_max');
22 |
23 | final int Function() crypto_generichash_keybytes =
24 | libsodium.lookupSizet('crypto_generichash_keybytes');
25 |
26 | final Pointer Function() crypto_generichash_primitive = libsodium
27 | .lookup Function()>>(
28 | 'crypto_generichash_primitive')
29 | .asFunction();
30 |
31 | final int Function() crypto_generichash_statebytes =
32 | libsodium.lookupSizet('crypto_generichash_statebytes');
33 |
34 | final int Function(Pointer out, int outlen, Pointer i,
35 | int inlen, Pointer key, int keylen) crypto_generichash =
36 | libsodium
37 | .lookup<
38 | NativeFunction<
39 | Int32 Function(Pointer, IntPtr, Pointer, Uint64,
40 | Pointer, IntPtr)>>('crypto_generichash')
41 | .asFunction();
42 |
43 | final int Function(
44 | Pointer state, Pointer key, int keylen, int outlen)
45 | crypto_generichash_init = libsodium
46 | .lookup<
47 | NativeFunction<
48 | Int32 Function(Pointer, Pointer, IntPtr,
49 | IntPtr)>>('crypto_generichash_init')
50 | .asFunction();
51 |
52 | final int Function(Pointer state, Pointer