ldap_passwd 0.1.3

  • Readme
  • Changelog
  • Example
  • Installing
  • new50

ldap_passwd #

ldap_passwd v0.1.0 Build

Simple password utility for ldap userPassword writing using dart, you can find some alternatives in other language world.

What is it #

This is a simple lib and cli tool for generating or verifying the ldap userPassword.

It supports salted:

  • md5
  • sha1
  • sha224
  • sha256
  • sha384
  • sha512

How to use it #

CLI usage #

  1. download the prebuild binary from the release page.
  2. pub global activate ldap_passwd

LIB usage #

First add this dependence in your pubspec.yaml file, then import it in your app.

dependencies:
  ldap_passwd: ^0.1.0

or

dependencies:
  ldap_passwd:
    git: git://github.com/liudonghua123/ldap_passwd.git
import 'package:ldap_passwd/ldap_passwd.dart';
// ......
var ldapPasswd = LdapPasswd('<plain_password_here>');
var generated_hashed_password = generatePassword();
var isMatch = LdapPasswd.checkPassword(generated_hashed_password);

License #

MIT License

Copyright (c) 2020 liudonghua

0.0.1 #

  • Initial version, created by Donghua Liu

0.1.0 #

  • Fix github workflow build error.
  • bump version to 0.1.0

0.1.1 #

  • Fix executable not install correctly.

0.1.2 #

  • Add a example

0.1.3 #

  • Update project description

example/lib/main.dart

import 'dart:io';

import 'package:ldap_passwd/ldap_passwd.dart';
import 'package:args/args.dart';
import 'package:ansicolor/ansicolor.dart';

AnsiPen success = AnsiPen()..green();
AnsiPen info = AnsiPen()..blue();
AnsiPen warning = AnsiPen()..yellow();
AnsiPen error = AnsiPen()..red();

String commandUsage() {
  return '''
Usage: ldap_passwd <command> [options]

Commands:
  ldap-passwd.js check     Check the password and the hashed password is match
  ldap-passwd.js generate  Generate the hashed password from the plain password

  ''';
}

void main(List<String> arguments) {
  var parser = ArgParser();
  parser.addOption('password', abbr: 'p', help: 'plain password for checking');
  parser.addOption('hash', abbr: 'h', help: 'Hashed password for checking...');
  parser.addOption('encoder',
      abbr: 'e',
      help: 'The encoder for hash, like md5, sha1, sha256, ...',
      defaultsTo: 'sha1');
  parser.addFlag('suffixed',
      negatable: false,
      help: 'Wether the salt prefixed or suffixed',
      defaultsTo: true);
  parser.addOption('salt',
      abbr: 's',
      help: 'Salt, 8 bytes string or 12-length base64',
      defaultsTo: null);
  parser.addOption('salt_size',
      help: 'salt length in hex format, equals to 8 bytes or 12-length base64',
      defaultsTo: '16');
  parser.addFlag('help', negatable: false);

  var argResults;
  try {
    argResults = parser.parse(arguments);
  } catch (e) {
    print(error(e.toString()));
    print(info(commandUsage()));
    print(info(parser.usage));
    exit(-1);
  }

  if (argResults['help']) {
    print(info(commandUsage()));
    print(info(parser.usage));
    exit(0);
  }

  if (argResults.rest.isEmpty) {
    print(warning('command should be specified as check or generate'));
    print(info(commandUsage()));
    print(info(parser.usage));
    exit(-1);
  }
  var command = argResults.rest[0];
  if (argResults.rest.length != 1 ||
      (command != 'check' && command != 'generate')) {
    print(warning('command need to be check or generate'));
    print(info(commandUsage()));
    print(info(parser.usage));
    exit(-1);
  }
  var ldapPasswd = LdapPasswd(argResults['password'],
      salt: argResults['salt'],
      saltSize: int.parse(argResults['salt_size']),
      encoder: argResults['encoder'],
      suffixed: argResults['suffixed']);
  switch (command) {
    case 'check':
      var result = ldapPasswd.checkPassword(argResults['hash']);
      if (result) {
        print(success('check result: ${result}'));
      } else {
        print(warning('check result: ${result}'));
      }
      break;
    case 'generate':
      var result = ldapPasswd.generatePassword();
      print(success('generate result: ${result}'));
      break;
  }
}

Use this package as an executable

1. Install it

You can install the package from the command line:


$ pub global activate ldap_passwd

2. Use it

The package has the following executables:


$ ldap_passwd

Use this package as a library

1. Depend on it

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


dependencies:
  ldap_passwd: ^0.1.3

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

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

3. Import it

Now in your Dart code, you can use:


import 'package:ldap_passwd/ldap_passwd.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
50
Learn more about scoring.

We analyzed this package on Mar 30, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.6

Health issues and suggestions

Document public APIs. (-1 points)

15 out of 15 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.0 <3.0.0
ansicolor ^1.0.2 1.0.2
args ^1.5.3 1.6.0
convert ^2.1.1 2.1.1
crypto ^2.1.4 2.1.4
Transitive dependencies
charcode 1.1.3
collection 1.14.12
typed_data 1.1.6
Dev dependencies
pedantic ^1.8.0
test ^1.6.0