protect 0.0.2 copy "protect: ^0.0.2" to clipboard
protect: ^0.0.2 copied to clipboard

outdated

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);
  }
}
7
likes
40
points
2.99k
downloads

Publisher

verified publisherjustkawal.dev

Weekly Downloads

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

Repository (GitHub)

License

MIT (license)

Dependencies

aes_crypt, crypto, utf, xml_parser

More

Packages that depend on protect