ninja 1.0.0

  • README.md
  • CHANGELOG.md
  • Installing
  • Versions
  • new69

ninja

Encryption and Decryption cryptographic algorithms exposed as Dart's Converter and Codec interfaces.

AES

AES is symmetric-key encryption algorithm. Class AES implements Converter<String, String> to encrypt and decrypt data. It expects a key. By default, PKCS7Padded is used for padding. This can be configured using padder parameter.

Encryption

Use encode method to encode clear text.

main() {
  final aes = AES.fromBytes(Uint8List.fromList(List.generate(16, (i) => i)));
  String value = aes.encode('Dart');
  print(value);
}

Decryption

Use decode method to decode to clear text.

main() {
  final aes = AES.fromBytes(Uint8List.fromList(List.generate(16, (i) => i)));
  String decoded = aes.decode('3347391e8789852b5c1b6ff1d3c44d0c');
  print(decoded);
}

RSA

RSA is an asymmetric-key encryption algorithm. Class RSA implements Converter<String, String> to encrypt and decrypt data.

It expects a key. If the key is RSAPublicKey, it can only encode. If the key is RSAPrivateKey, it can both encode and decode.

Encryption

main() {
  final key = RSAPublicKey(
      BigInt.parse(
          "20620915813302906913761247666337410938401372343750709187749515126790853245302593205328533062154315527282056175455193812046134139935830222032257750866653461677566720508752544506266533943725970345491747964654489405936145559121373664620352701801574863309087932865304205561439525871868738640172656811470047745445089832193075388387376667722031640892525639171016297098395245887609359882693921643396724693523583076582208970794545581164952427577506035951122669158313095779596666008591745562008787129160302313244329988240795948461701615228062848622019620094307696506764461083870202605984497833670577046553861732258592935325691"),
      BigInt.parse("65537"));
    final rsa = RSA(key);
    String encoded =
        rsa.encode('Lorem ipsum dolor sit amet, consectetur adipiscing elit...');
    print(encoded);
}

Decryption

main() {
  final key = RSAPrivateKey(
      BigInt.parse(
          "20620915813302906913761247666337410938401372343750709187749515126790853245302593205328533062154315527282056175455193812046134139935830222032257750866653461677566720508752544506266533943725970345491747964654489405936145559121373664620352701801574863309087932865304205561439525871868738640172656811470047745445089832193075388387376667722031640892525639171016297098395245887609359882693921643396724693523583076582208970794545581164952427577506035951122669158313095779596666008591745562008787129160302313244329988240795948461701615228062848622019620094307696506764461083870202605984497833670577046553861732258592935325691"),
      BigInt.parse("65537"),
      BigInt.parse(
          "11998058528661160053642124235359844880039079149364512302169225182946866898849176558365314596732660324493329967536772364327680348872134489319530228055102152992797567579226269544119435926913937183793755182388650533700918602627770886358900914370472445911502526145837923104029967812779021649252540542517598618021899291933220000807916271555680217608559770825469218984818060775562259820009637370696396889812317991880425127772801187664191059506258517954313903362361211485802288635947903604738301101038823790599295749578655834195416886345569976295245464597506584866355976650830539380175531900288933412328525689718517239330305"),
      BigInt.parse(
          "144173682842817587002196172066264549138375068078359231382946906898412792452632726597279520229873489736777248181678202636100459215718497240474064366927544074501134727745837254834206456400508719134610847814227274992298238973375146473350157304285346424982280927848339601514720098577525635486320547905945936448443"),
      BigInt.parse(
          "143028293421514654659358549214971921584534096938352096320458818956414890934365483375293202045679474764569937266017713262196941957149321696805368542065644090886347646782188634885321277533175667840285448510687854061424867903968633218073060468434469761149335255007464091258725753837522484082998329871306803923137"));

  final rsa = RSA(key);
  String decoded = rsa.decode(encoded);
  print(decoded);
}

1.0.0

  • Architecture
  • Added
    • AES
    • RSA

Use this package as a library

1. Depend on it

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


dependencies:
  ninja: ^1.0.0

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:ninja/ninja.dart';
  
Version Uploaded Documentation Archive
1.0.0 Jul 12, 2018 Go to the documentation of ninja 1.0.0 Download ninja 1.0.0 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
46
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
80
Overall:
Weighted score of the above. [more]
69
Learn more about scoring.

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

  • Dart: 2.0.0-dev.69.0
  • pana: 0.11.7

Platforms

Detected platforms: Flutter, web, other

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

Issues and suggestions

Support Dart 2 in pubspec.yaml.

The SDK constraint in pubspec.yaml doesn't allow the Dart 2.0.0 release. For information about upgrading it to be Dart 2 compatible, please see https://www.dartlang.org/dart-2#migration.

Format lib/asymmetric/rsa.dart.

Run dartfmt to format lib/asymmetric/rsa.dart.

Format lib/utils/hex_string.dart.

Run dartfmt to format lib/utils/hex_string.dart.

Maintain an example.

None of the files in your example/ directory matches a known example patterns. Common file name patterns include: main.dart, example.dart or you could also use ninja.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.60.0 <2.0.0
pointycastle ^1.0.0-rc2 1.0.0-rc2
Transitive dependencies
analyzer 0.31.1 0.32.3
args 1.4.4
async 2.0.8
barback 0.15.2+16
build 0.12.7+2
build_barback 0.5.0+4
build_config 0.2.6+2 0.3.1+1
build_resolvers 0.2.1+1
build_runner 0.8.3 0.9.2
built_collection 3.1.1
built_value 5.5.3
charcode 1.1.2
cli_util 0.1.3+2
code_builder 3.1.2
code_transformers 0.5.1+5
collection 1.14.11
convert 2.0.2
crypto 2.0.6
csslib 0.14.4+1
dart2_constant 1.0.1+dart2
dart_style 1.0.9+1 1.1.3
fixnum 0.10.8
front_end 0.1.0-alpha.9 0.1.3
glob 1.1.7
graphs 0.1.2+1
html 0.13.3+2
http 0.11.3+17
http_multi_server 2.0.5
http_parser 3.1.3
io 0.3.3
isolate 1.1.0 2.0.2
kernel 0.3.0-alpha.9 0.3.3
logging 0.11.3+2
matcher 0.12.4
meta 1.1.6
mime 0.9.6+1
package_config 1.0.5
package_resolver 1.0.3
path 1.6.2
plugin 0.2.0+3
pool 1.3.5
quiver 0.29.0+2 2.0.0+1
reflectable 2.0.1
shelf 0.7.3+3
source_maps 0.10.7
source_span 1.4.1
stack_trace 1.9.3
stream_channel 1.6.8
stream_transform 0.0.14+1
string_scanner 1.0.3
typed_data 1.1.6
utf 0.9.0+5
watcher 0.9.7+10
yaml 2.1.15
Dev dependencies
test ^1.2.0