diff --git a/README.md b/README.md index 48728d8..b8a2fd5 100644 --- a/README.md +++ b/README.md @@ -207,6 +207,7 @@ If the input has spaces inside, simply surround it with quotes. Downloads --------- +* [Distributions](https://github.com/dcodeIO/bcrypt.js/tree/master/dist) * [ZIP-Archive](https://github.com/dcodeIO/bcrypt.js/archive/master.zip) * [Tarball](https://github.com/dcodeIO/bcrypt.js/tarball/master) diff --git a/bin/bcrypt b/bin/bcrypt index a72df10..5e61bb0 100644 --- a/bin/bcrypt +++ b/bin/bcrypt @@ -1,7 +1,7 @@ #!/usr/bin/env node var path = require("path"), - bcrypt = require(path.join(__dirname, '..', 'bcrypt.js')), + bcrypt = require(path.join(__dirname, '..', 'index.js')), pkg = require(path.join(__dirname, '..', 'package.json')); if (process.argv.length < 3) { diff --git a/bcrypt.js b/dist/bcrypt.js similarity index 100% rename from bcrypt.js rename to dist/bcrypt.js diff --git a/bcrypt.min.js b/dist/bcrypt.min.js similarity index 100% rename from bcrypt.min.js rename to dist/bcrypt.min.js diff --git a/index.js b/index.js new file mode 100644 index 0000000..df60d47 --- /dev/null +++ b/index.js @@ -0,0 +1,31 @@ +/* + Copyright (c) 2012 Nevins Bartolomeo + Copyright (c) 2012 Shane Girish + Copyright (c) 2013 Daniel Wirtz + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 3. The name of the author may not be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +var path = require("path"), + bcrypt = require(path.join(__dirname, "dist", "bcrypt.js")); + +module.exports = bcrypt; diff --git a/package.json b/package.json index 3145afc..a4364e2 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "bcryptjs", "description": "Optimized bcrypt in plain JavaScript with zero dependencies. 100% typed code. Fully compatible to 'bcrypt'.", - "version": "1.0.0-pre", + "version": "1.0.0", "author": "Daniel Wirtz ", "contributors": [ "Shane Girish (https://github.com/shaneGirish)", @@ -26,18 +26,19 @@ "crypt", "crypto" ], - "main": "./bcrypt.min.js", + "main": "index.js", "dependencies": {}, "devDependencies": { "testjs": "latest", "preprocessor": "latest", - "closurecompiler": "latest" + "closurecompiler": "latest", + "bcrypt": "latest" }, "license": "Apache-2.0", "scripts": { "test": "node node_modules/testjs/bin/testjs", - "build": "preprocess ./src/bcrypt.js ./src > ./bcrypt.js", - "compile": "ccjs bcrypt.js --warning_level=VERBOSE --compilation_level=ADVANCED_OPTIMIZATIONS --externs=externs/minimal-env.js > bcrypt.min.js", + "build": "preprocess ./src/bcrypt.js ./src > ./dist/bcrypt.js", + "compile": "ccjs dist/bcrypt.js --warning_level=VERBOSE --compilation_level=ADVANCED_OPTIMIZATIONS --externs=externs/minimal-env.js > dist/bcrypt.min.js", "make": "npm run-script build && npm run-script compile && npm test" } } \ No newline at end of file diff --git a/tests/quickbrown.txt b/tests/quickbrown.txt new file mode 100644 index 0000000..81e850f --- /dev/null +++ b/tests/quickbrown.txt @@ -0,0 +1,150 @@ +Sentences that contain all letters commonly used in a language +-------------------------------------------------------------- + +Markus Kuhn -- 2012-04-11 + +This is an example of a plain-text file encoded in UTF-8. + + +Danish (da) +--------- + + Quizdeltagerne spiste jordbær med fløde, mens cirkusklovnen + Wolther spillede på xylofon. + (= Quiz contestants were eating strawbery with cream while Wolther + the circus clown played on xylophone.) + +German (de) +----------- + + Falsches Üben von Xylophonmusik quält jeden größeren Zwerg + (= Wrongful practicing of xylophone music tortures every larger dwarf) + + Zwölf Boxkämpfer jagten Eva quer über den Sylter Deich + (= Twelve boxing fighters hunted Eva across the dike of Sylt) + + Heizölrückstoßabdämpfung + (= fuel oil recoil absorber) + (jqvwxy missing, but all non-ASCII letters in one word) + +Greek (el) +---------- + + Γαζέες καὶ μυρτιὲς δὲν θὰ βρῶ πιὰ στὸ χρυσαφὶ ξέφωτο + (= No more shall I see acacias or myrtles in the golden clearing) + + Ξεσκεπάζω τὴν ψυχοφθόρα βδελυγμία + (= I uncover the soul-destroying abhorrence) + +English (en) +------------ + + The quick brown fox jumps over the lazy dog + +Spanish (es) +------------ + + El pingüino Wenceslao hizo kilómetros bajo exhaustiva lluvia y + frío, añoraba a su querido cachorro. + (Contains every letter and every accent, but not every combination + of vowel + acute.) + +French (fr) +----------- + + Portez ce vieux whisky au juge blond qui fume sur son île intérieure, à + côté de l'alcôve ovoïde, où les bûches se consument dans l'âtre, ce + qui lui permet de penser à la cænogenèse de l'être dont il est question + dans la cause ambiguë entendue à Moÿ, dans un capharnaüm qui, + pense-t-il, diminue çà et là la qualité de son œuvre. + + l'île exiguë + Où l'obèse jury mûr + Fête l'haï volapük, + Âne ex aéquo au whist, + Ôtez ce vœu déçu. + + Le cœur déçu mais l'âme plutôt naïve, Louÿs rêva de crapaüter en + canoë au delà des îles, près du mälström où brûlent les novæ. + +Irish Gaelic (ga) +----------------- + + D'fhuascail Íosa, Úrmhac na hÓighe Beannaithe, pór Éava agus Ádhaimh + +Hungarian (hu) +-------------- + + Árvíztűrő tükörfúrógép + (= flood-proof mirror-drilling machine, only all non-ASCII letters) + +Icelandic (is) +-------------- + + Kæmi ný öxi hér ykist þjófum nú bæði víl og ádrepa + + Sævör grét áðan því úlpan var ónýt + (some ASCII letters missing) + +Japanese (jp) +------------- + + Hiragana: (Iroha) + + いろはにほへとちりぬるを + わかよたれそつねならむ + うゐのおくやまけふこえて + あさきゆめみしゑひもせす + + Katakana: + + イロハニホヘト チリヌルヲ ワカヨタレソ ツネナラム + ウヰノオクヤマ ケフコエテ アサキユメミシ ヱヒモセスン + +Hebrew (iw) +----------- + + ? דג סקרן שט בים מאוכזב ולפתע מצא לו חברה איך הקליטה + +Polish (pl) +----------- + + Pchnąć w tę łódź jeża lub ośm skrzyń fig + (= To push a hedgehog or eight bins of figs in this boat) + +Russian (ru) +------------ + + В чащах юга жил бы цитрус? Да, но фальшивый экземпляр! + (= Would a citrus live in the bushes of south? Yes, but only a fake one!) + + Съешь же ещё этих мягких французских булок да выпей чаю + (= Eat some more of these fresh French loafs and have some tea) + +Thai (th) +--------- + + [--------------------------|------------------------] + ๏ เป็นมนุษย์สุดประเสริฐเลิศคุณค่า กว่าบรรดาฝูงสัตว์เดรัจฉาน + จงฝ่าฟันพัฒนาวิชาการ อย่าล้างผลาญฤๅเข่นฆ่าบีฑาใคร + ไม่ถือโทษโกรธแช่งซัดฮึดฮัดด่า หัดอภัยเหมือนกีฬาอัชฌาสัย + ปฏิบัติประพฤติกฎกำหนดใจ พูดจาให้จ๊ะๆ จ๋าๆ น่าฟังเอย ฯ + + [The copyright for the Thai example is owned by The Computer + Association of Thailand under the Royal Patronage of His Majesty the + King.] + +Turkish (tr) +------------ + + Pijamalı hasta, yağız şoföre çabucak güvendi. + (=Patient with pajamas, trusted swarthy driver quickly) + + +Special thanks to the people from all over the world who contributed +these sentences since 1999. + +A much larger collection of such pangrams is now available at + + http://en.wikipedia.org/wiki/List_of_pangrams + diff --git a/tests/suite.js b/tests/suite.js index 68c7282..8a7b9d0 100644 --- a/tests/suite.js +++ b/tests/suite.js @@ -1,5 +1,7 @@ var path = require("path"), - bcrypt = require(path.join(__dirname, '..', 'bcrypt.js')); + fs = require("fs"), + binding = require("bcrypt"), + bcrypt = require(path.join(__dirname, '..', 'index.js')); module.exports = { @@ -82,5 +84,14 @@ module.exports = { var hash1 = bcrypt.hashSync("hello", bcrypt.genSaltSync()); test.equal(bcrypt.getRounds(hash1), 10); test.done(); + }, + + "compat": function(test) { + var pass = fs.readFileSync(path.join(__dirname, "quickbrown.txt"))+"", + salt = bcrypt.genSaltSync(), + hash1 = binding.hashSync(pass, salt), + hash2 = bcrypt.hashSync(pass, salt); + test.equal(hash1, hash2); + test.done(); } };