Skip to content

Commit 0e974f0

Browse files
committed
Validate (UTF8) compatibility with bcrypt, fixes #4
1 parent d6bfbac commit 0e974f0

File tree

8 files changed

+201
-7
lines changed

8 files changed

+201
-7
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ If the input has spaces inside, simply surround it with quotes.
207207

208208
Downloads
209209
---------
210+
* [Distributions](https://github.com/dcodeIO/bcrypt.js/tree/master/dist)
210211
* [ZIP-Archive](https://github.com/dcodeIO/bcrypt.js/archive/master.zip)
211212
* [Tarball](https://github.com/dcodeIO/bcrypt.js/tarball/master)
212213

bin/bcrypt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env node
22

33
var path = require("path"),
4-
bcrypt = require(path.join(__dirname, '..', 'bcrypt.js')),
4+
bcrypt = require(path.join(__dirname, '..', 'index.js')),
55
pkg = require(path.join(__dirname, '..', 'package.json'));
66

77
if (process.argv.length < 3) {
File renamed without changes.
File renamed without changes.

index.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
Copyright (c) 2012 Nevins Bartolomeo <nevins.bartolomeo@gmail.com>
3+
Copyright (c) 2012 Shane Girish <shaneGirish@gmail.com>
4+
Copyright (c) 2013 Daniel Wirtz <dcode@dcode.io>
5+
6+
Redistribution and use in source and binary forms, with or without
7+
modification, are permitted provided that the following conditions
8+
are met:
9+
1. Redistributions of source code must retain the above copyright
10+
notice, this list of conditions and the following disclaimer.
11+
2. Redistributions in binary form must reproduce the above copyright
12+
notice, this list of conditions and the following disclaimer in the
13+
documentation and/or other materials provided with the distribution.
14+
3. The name of the author may not be used to endorse or promote products
15+
derived from this software without specific prior written permission.
16+
17+
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18+
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19+
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20+
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22+
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26+
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27+
*/
28+
var path = require("path"),
29+
bcrypt = require(path.join(__dirname, "dist", "bcrypt.js"));
30+
31+
module.exports = bcrypt;

package.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "bcryptjs",
33
"description": "Optimized bcrypt in plain JavaScript with zero dependencies. 100% typed code. Fully compatible to 'bcrypt'.",
4-
"version": "1.0.0-pre",
4+
"version": "1.0.0",
55
"author": "Daniel Wirtz <dcode@dcode.io>",
66
"contributors": [
77
"Shane Girish <shaneGirish@gmail.com> (https://github.com/shaneGirish)",
@@ -26,18 +26,19 @@
2626
"crypt",
2727
"crypto"
2828
],
29-
"main": "./bcrypt.min.js",
29+
"main": "index.js",
3030
"dependencies": {},
3131
"devDependencies": {
3232
"testjs": "latest",
3333
"preprocessor": "latest",
34-
"closurecompiler": "latest"
34+
"closurecompiler": "latest",
35+
"bcrypt": "latest"
3536
},
3637
"license": "Apache-2.0",
3738
"scripts": {
3839
"test": "node node_modules/testjs/bin/testjs",
39-
"build": "preprocess ./src/bcrypt.js ./src > ./bcrypt.js",
40-
"compile": "ccjs bcrypt.js --warning_level=VERBOSE --compilation_level=ADVANCED_OPTIMIZATIONS --externs=externs/minimal-env.js > bcrypt.min.js",
40+
"build": "preprocess ./src/bcrypt.js ./src > ./dist/bcrypt.js",
41+
"compile": "ccjs dist/bcrypt.js --warning_level=VERBOSE --compilation_level=ADVANCED_OPTIMIZATIONS --externs=externs/minimal-env.js > dist/bcrypt.min.js",
4142
"make": "npm run-script build && npm run-script compile && npm test"
4243
}
4344
}

tests/quickbrown.txt

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
Sentences that contain all letters commonly used in a language
2+
--------------------------------------------------------------
3+
4+
Markus Kuhn <http://www.cl.cam.ac.uk/~mgk25/> -- 2012-04-11
5+
6+
This is an example of a plain-text file encoded in UTF-8.
7+
8+
9+
Danish (da)
10+
---------
11+
12+
Quizdeltagerne spiste jordbær med fløde, mens cirkusklovnen
13+
Wolther spillede på xylofon.
14+
(= Quiz contestants were eating strawbery with cream while Wolther
15+
the circus clown played on xylophone.)
16+
17+
German (de)
18+
-----------
19+
20+
Falsches Üben von Xylophonmusik quält jeden größeren Zwerg
21+
(= Wrongful practicing of xylophone music tortures every larger dwarf)
22+
23+
Zwölf Boxkämpfer jagten Eva quer über den Sylter Deich
24+
(= Twelve boxing fighters hunted Eva across the dike of Sylt)
25+
26+
Heizölrückstoßabdämpfung
27+
(= fuel oil recoil absorber)
28+
(jqvwxy missing, but all non-ASCII letters in one word)
29+
30+
Greek (el)
31+
----------
32+
33+
Γαζέες καὶ μυρτιὲς δὲν θὰ βρῶ πιὰ στὸ χρυσαφὶ ξέφωτο
34+
(= No more shall I see acacias or myrtles in the golden clearing)
35+
36+
Ξεσκεπάζω τὴν ψυχοφθόρα βδελυγμία
37+
(= I uncover the soul-destroying abhorrence)
38+
39+
English (en)
40+
------------
41+
42+
The quick brown fox jumps over the lazy dog
43+
44+
Spanish (es)
45+
------------
46+
47+
El pingüino Wenceslao hizo kilómetros bajo exhaustiva lluvia y
48+
frío, añoraba a su querido cachorro.
49+
(Contains every letter and every accent, but not every combination
50+
of vowel + acute.)
51+
52+
French (fr)
53+
-----------
54+
55+
Portez ce vieux whisky au juge blond qui fume sur son île intérieure, à
56+
côté de l'alcôve ovoïde, où les bûches se consument dans l'âtre, ce
57+
qui lui permet de penser à la cænogenèse de l'être dont il est question
58+
dans la cause ambiguë entendue à Moÿ, dans un capharnaüm qui,
59+
pense-t-il, diminue çà et là la qualité de son œuvre.
60+
61+
l'île exiguë
62+
Où l'obèse jury mûr
63+
Fête l'haï volapük,
64+
Âne ex aéquo au whist,
65+
Ôtez ce vœu déçu.
66+
67+
Le cœur déçu mais l'âme plutôt naïve, Louÿs rêva de crapaüter en
68+
canoë au delà des îles, près du mälström où brûlent les novæ.
69+
70+
Irish Gaelic (ga)
71+
-----------------
72+
73+
D'fhuascail Íosa, Úrmhac na hÓighe Beannaithe, pór Éava agus Ádhaimh
74+
75+
Hungarian (hu)
76+
--------------
77+
78+
Árvíztűrő tükörfúrógép
79+
(= flood-proof mirror-drilling machine, only all non-ASCII letters)
80+
81+
Icelandic (is)
82+
--------------
83+
84+
Kæmi ný öxi hér ykist þjófum nú bæði víl og ádrepa
85+
86+
Sævör grét áðan því úlpan var ónýt
87+
(some ASCII letters missing)
88+
89+
Japanese (jp)
90+
-------------
91+
92+
Hiragana: (Iroha)
93+
94+
いろはにほへとちりぬるを
95+
わかよたれそつねならむ
96+
うゐのおくやまけふこえて
97+
あさきゆめみしゑひもせす
98+
99+
Katakana:
100+
101+
イロハニホヘト チリヌルヲ ワカヨタレソ ツネナラム
102+
ウヰノオクヤマ ケフコエテ アサキユメミシ ヱヒモセスン
103+
104+
Hebrew (iw)
105+
-----------
106+
107+
? דג סקרן שט בים מאוכזב ולפתע מצא לו חברה איך הקליטה
108+
109+
Polish (pl)
110+
-----------
111+
112+
Pchnąć w tę łódź jeża lub ośm skrzyń fig
113+
(= To push a hedgehog or eight bins of figs in this boat)
114+
115+
Russian (ru)
116+
------------
117+
118+
В чащах юга жил бы цитрус? Да, но фальшивый экземпляр!
119+
(= Would a citrus live in the bushes of south? Yes, but only a fake one!)
120+
121+
Съешь же ещё этих мягких французских булок да выпей чаю
122+
(= Eat some more of these fresh French loafs and have some tea)
123+
124+
Thai (th)
125+
---------
126+
127+
[--------------------------|------------------------]
128+
๏ เป็นมนุษย์สุดประเสริฐเลิศคุณค่า กว่าบรรดาฝูงสัตว์เดรัจฉาน
129+
จงฝ่าฟันพัฒนาวิชาการ อย่าล้างผลาญฤๅเข่นฆ่าบีฑาใคร
130+
ไม่ถือโทษโกรธแช่งซัดฮึดฮัดด่า หัดอภัยเหมือนกีฬาอัชฌาสัย
131+
ปฏิบัติประพฤติกฎกำหนดใจ พูดจาให้จ๊ะๆ จ๋าๆ น่าฟังเอย ฯ
132+
133+
[The copyright for the Thai example is owned by The Computer
134+
Association of Thailand under the Royal Patronage of His Majesty the
135+
King.]
136+
137+
Turkish (tr)
138+
------------
139+
140+
Pijamalı hasta, yağız şoföre çabucak güvendi.
141+
(=Patient with pajamas, trusted swarthy driver quickly)
142+
143+
144+
Special thanks to the people from all over the world who contributed
145+
these sentences since 1999.
146+
147+
A much larger collection of such pangrams is now available at
148+
149+
http://en.wikipedia.org/wiki/List_of_pangrams
150+

tests/suite.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
var path = require("path"),
2-
bcrypt = require(path.join(__dirname, '..', 'bcrypt.js'));
2+
fs = require("fs"),
3+
binding = require("bcrypt"),
4+
bcrypt = require(path.join(__dirname, '..', 'index.js'));
35

46
module.exports = {
57

@@ -82,5 +84,14 @@ module.exports = {
8284
var hash1 = bcrypt.hashSync("hello", bcrypt.genSaltSync());
8385
test.equal(bcrypt.getRounds(hash1), 10);
8486
test.done();
87+
},
88+
89+
"compat": function(test) {
90+
var pass = fs.readFileSync(path.join(__dirname, "quickbrown.txt"))+"",
91+
salt = bcrypt.genSaltSync(),
92+
hash1 = binding.hashSync(pass, salt),
93+
hash2 = bcrypt.hashSync(pass, salt);
94+
test.equal(hash1, hash2);
95+
test.done();
8596
}
8697
};

0 commit comments

Comments
 (0)