npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

pbkdf2-hx

v0.0.2

Published

Haxe implementation of the PBKDF2 Algorithm for password hashing

Downloads

2

Readme

PBKDF2 for Haxe

PBKDF2 (Password-Based Key Derivation Function 2) is a key derivation function that you can read all about on Wikipedia.

Basically, it lets you do a hash similar to MD5 or SHA1, but with a salt, and it can repeat thousands of times to make it harder to crack - the longer it takes to generate the key the longer it will take to crack. Anyway, it is a good way to store user passwords. Even big frameworks like Django use it by default.

Installation

To install on haxelib:

haxelib install pbkdf2

And then in your project's hxml build file, add

-lib pbkdf2

To install from the latest GIT, or from a fork:

Usage

var str = PBKDF2.encode(pass, salt, numIterations, numBytes);

It's best to use a different salt for each unique password... Here I use the helper from the Random haxelib.

user = new User();
user.username = "jason";
user.salt = Random.string(20);
user.password = PBKDF2.encode("password", user.salt, 1000, 20);

Asynchronous Usage

On targets that support haxe.Timer (flash8, flash, js, cs, java) you can use the Async version:

var onComplete = function(str:String) {
	trace ("Hash is " + str);
}

PBKDF2.encodeAsync("password", "salt", 1000, 20, onComplete);

Platform Support

Currently tested on Flash9, JS, CPP. Works on PHP, but our test suite doesn't run. I did some manual tests to verify though.

Neko only works with v2.0, so you'll need to install the release candidate or latest SVN. You'll also need Haxe3 (latest SVN), and you will need to use the -D neko_v2 command line option. It will not work on Neko v1.8, because the algorithm relies heavily on Bitwise Integer operations and neko v1 does not support 32bit Integers, so a lot of things were broken that I have not debugged.
Currently, neko does work but runs incredibly slowly - 60 times slower than JS and 120 times slower than CPP. Some profiling will definitely be needed.

No idea if it works on Java or C#, but quite possibly - if their Integer operations and arrays behave similarly enough.

Does not work on Flash8 (generates different numbers, have not debugged yet).

Attribution & Licence

This is a copy-of-a-copy-of-a-derivative, and a separate port:

  1. The Javascript version: Copyright (c) 2007, Parvez Anandam
    [email protected]
    http://anandam.name/pbkdf2
    (Uses Paul Johnston's excellent SHA-1 JavaScript library sha1.js)
    Thanks to Felix Gartsman for pointing out a bug in version 1.0
    BSD License

  2. The AS3 version: http://code.google.com/p/as3-pbkdf2/
    [email protected]
    BSD License

  3. Haxe implementation by Jason O'Neil
    https://github.com/jasononeil/PBKDF2-Haxe
    BSD license

  4. The PHP implementation was derived from:
    https://defuse.ca/php-pbkdf2.htm havoc AT defuse.ca
    Released under Public Domain. Haxe translation by Jason O'Neil.

See the LICENSE.txt file for the full license.

Making Changes

  • Edit src/PBKDF2.hx
  • Add unit tests to test/PBKDF2Test.hx
  • haxelib run munit t - run unit tests, check all are passing
  • haxelib run mlib v - increment version number
  • haxelib run mlib submit - submit to Haxelib