encrypt 0.2.0+2

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 89

encrypt

Pub Package Build Status Donate

A set of high-level APIs over PointyCastle for two-way cryptography.

Looking for password hashing? Please, visit password.

AES (Block Cipher)

import 'package:encrypt/encrypt.dart';

void main() {
  final key = 'my32lengthsupersecretnooneknows1';

  final encrypter = new Encrypter(new AES(key));
  final plainText = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit ........';

  final encryptedText = encrypter.encrypt(plainText);
  final decryptedText = encrypter.decrypt(encryptedText);

  print(encryptedText); // db066ce180f62f020617eb720b891c1efcc48b217cb83272812a8efe3b30e7eae4373ddcede4ea77bdae77d126d95457b3759b1983bf4cb4a6a5b051a5690bdf
  print(decryptedText); // Lorem ipsum dolor sit amet, consectetur adipiscing elit ........
}

Salsa20 (Stream Cipher)

import 'package:encrypt/encrypt.dart';

void main() {
  final key = 'private!!!!!!!!!';
  final iv = '8bytesiv'; // https://en.wikipedia.org/wiki/Initialization_vector
  final plainText = 'Secret';

  final encrypter = new Encrypter(new Salsa20(key, iv));

  final encrypted = encrypter.encrypt(plainText);
  final decrypted = encrypter.decrypt(encrypted);

  print(encrypted); // c5cc91943cf0
  print(decrypted); // Secret
}

Salsa20 With Chinese

import 'package:encrypt/encrypt.dart';

void main() {
  final key = '1234567890123456';
  final iv = '8bytesiv';
  final encryptor = Encrypter(Salsa20(key, iv));
  String text = '你好';
  String base64Text = base64.encode(utf8.encode(text));
  String encText  = encryptor.encrypt(base64Text);
  var decStr = utf8.decode(base64.decode(encryptor.decrypt(encText)));

  print('origin:'+text);//你好
  print('base64Text:'+base64Text);//5L2g5aW9
  print('enc text:'+encText);//c72f29fd34b15145
  print('dec text:'+decStr);//你好
}

RSA (Asymmetric)

TODO

0.2.0+2

  • Remove unnecessary news
  • Improve static typing
  • Add examples index (README)

0.2.0+1

  • Refresh dependencies, make sure it works on Dart 2.

example/README.md

Encrypt examples

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  encrypt: ^0.2.0+2

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:encrypt/encrypt.dart';
  
Version Uploaded Documentation Archive
0.2.0+2 Oct 28, 2018 Go to the documentation of encrypt 0.2.0+2 Download encrypt 0.2.0+2 archive
0.2.0+1 Oct 28, 2018 Go to the documentation of encrypt 0.2.0+1 Download encrypt 0.2.0+1 archive
0.2.0 Jul 3, 2018 Go to the documentation of encrypt 0.2.0 Download encrypt 0.2.0 archive
0.1.0 Jul 3, 2018 Go to the documentation of encrypt 0.1.0 Download encrypt 0.1.0 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
78
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
89
Learn more about scoring.

We analyzed this package on Nov 14, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0
  • pana: 0.12.6

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:encrypt/encrypt.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
pointycastle ^1.0.0-rc4 1.0.0-rc4
Dev dependencies
test ^1.3.4