protect 0.0.2
protect: ^0.0.2 copied to clipboard

Protect protects excel files with password and also helps to decrypt the password protected excel files

example/example.dart

import 'dart:io';
import 'package:protect/protect.dart';

void main() async {
  ///
  /// Applying password protection
  ///
  var unprotectedBytes =
      await File('/Users/kawal/Desktop/protect/resource/form.xlsx')
          .readAsBytes();
  ProtectResponse protectedResponse =
      await Protect.encryptBytes(unprotectedBytes, 'contact@kawal.dev');

  if (protectedResponse.isDataValid) {
    var outputProtectedFile =
        '/Users/kawal/Desktop/protect/resource/form_encrypted_file.xlsx';
    await File(outputProtectedFile)
      ..create(recursive: true)
      ..writeAsBytes(protectedResponse.processedBytes);
  }

  ///
  /// Removing password protection and getting decryptedBytes from decrypt function
  ///
  var protectedBytesFile = await File(
          '/Users/kawal/Desktop/protect/resource/form_encrypted_file.xlsx')
      .readAsBytes();
  ProtectResponse unprotectedResponse =
      await Protect.decryptBytes(protectedBytesFile, 'contact@kawal.dev');

  if (unprotectedResponse.isDataValid) {
    var outputUnProtectedFile =
        '/Users/kawal/Desktop/protect/resource/form_decrypted.xlsx';
    await File(outputUnProtectedFile)
      ..create(recursive: true)
      ..writeAsBytes(unprotectedResponse.processedBytes);
  }
}
2
likes
80
pub points
18%
popularity

Protect protects excel files with password and also helps to decrypt the password protected excel files

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

aes_crypt, crypto, utf, xml_parser

More

Packages that depend on protect