prongbang / lazysecret

Lazysecret is a comprehensive Flutter implementation of the libsodium using secret_box library.

Home Page:https://pub.dev/packages/lazysecret

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

lazysecret

Lazysecret is a comprehensive Flutter implementation of the libsodium using secret_box library.

Usage

  • pubspec.yml
dependencies:
  lazysecret: ^1.0.2
  • Dart
final lazysecret = LazySecret.instance;

Function

  Future<Uint8List> randomBytesBuf(int size)

  Future<String> toHex(Uint8List bytes)

  Future<Uint8List> toBin(String hexString)

  Future<String> cryptoBoxBeforeNm(KeyPair keyPair)

  Future<String> cryptoSecretBoxEasy(String plaintext, String nonce, String key)

  Future<String> cryptoSecretBoxOpenEasy(String ciphertext, String nonce, String key)

  Future<KeyPair> cryptoKxKeyPair()

  Future<int> cryptoSecretBoxKeyBytes()

  Future<int> cryptoSecretBoxNonceBytes()

  Future<int> cryptoSecretBoxMacBytes()

Android

  • proguard-rules.pro
-keep class com.sun.jna.** { *; }
-keep class * implements com.sun.jna.** { *; }
-dontwarn java.awt.*
-keepclassmembers class * extends com.sun.jna.* { public *; }
-keepclassmembers class * extends com.sun.jna.** {
    <fields>;
    <methods>;
}

Web

  1. Download the sodium.js file

https://raw.githubusercontent.com/jedisct1/libsodium.js/master/dist/browsers-sumo/sodium.js

  1. Add sodium.js to web directory
.
└── web
    ├── ...
    └── sodium.js  <- here
  1. Add script in web/index.html
<script src="sodium.js"></script>
  1. Add LazySecret.init() in main.dart
void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  await LazySecret.init();

  runApp(const MyApp());
}

Documentation

https://libsodium.gitbook.io/doc/secret-key_cryptography/secretbox

Sodium is a modern, easy-to-use software library for encryption, decryption, signatures, password hashing, and more.

About

Lazysecret is a comprehensive Flutter implementation of the libsodium using secret_box library.

https://pub.dev/packages/lazysecret

License:Apache License 2.0


Languages

Language:Dart 35.0%Language:Swift 30.5%Language:Kotlin 25.1%Language:Ruby 5.3%Language:HTML 4.1%Language:Objective-C 0.1%