encrypt_decrypt_plus 2.0.0 copy "encrypt_decrypt_plus: ^2.0.0" to clipboard
encrypt_decrypt_plus: ^2.0.0 copied to clipboard

This package helps to encryption and decryption with or without secret key and JWT decode.

example/lib/main.dart

import 'package:encrypt_decrypt_plus/encrypt_decrypt/aes.dart';
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  final String _plainTxt = "Hello datadirr";
  String? _encryptTxt = "";
  String? _decryptTxt = "";
  final AES _aes = AES(secretKey: "datadirr", iv: "datadirr");

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: SafeArea(
          child: Center(
            child: Column(
              mainAxisSize: MainAxisSize.min,
              children: [
                Text("plainTxt: $_plainTxt"),
                ElevatedButton(
                  onPressed: () {
                    _encryptAES256CBC();
                  },
                  child: const Text("Encrypt"),
                ),
                Text("encryptTxt: $_encryptTxt"),
                ElevatedButton(
                  onPressed: () {
                    _decryptAES256CBC();
                  },
                  child: const Text("Decrypt"),
                ),
                Text("decryptTxt: $_decryptTxt"),
              ],
            ),
          ),
        ),
      ),
    );
  }

  void _encryptAES256CBC() async {
    _encryptTxt = await _aes.encryptAES256CBC(_plainTxt);
    setState(() {});
  }

  void _decryptAES256CBC() async {
    _decryptTxt = await _aes.decryptAES256CBC(_encryptTxt ?? "");
    setState(() {});
  }
}
9
likes
160
points
821
downloads

Publisher

verified publisherdatadirr.com

Weekly Downloads

This package helps to encryption and decryption with or without secret key and JWT decode.

Homepage
Repository (GitHub)

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

encrypt, flutter, flutter_web_plugins, plugin_platform_interface, web

More

Packages that depend on encrypt_decrypt_plus