1
+ var bcrypt = require ( '../bcrypt' ) ;
2
+
3
+ // some tests were adapted from https://github.com/riverrun/bcrypt_elixir/blob/master/test/base_test.exs
4
+ // which are under the BSD LICENSE
5
+ module . exports = {
6
+ openwall_bcrypt_tests : function ( assert ) {
7
+ assert . strictEqual ( bcrypt . hashSync ( "U*U" , "$2a$05$CCCCCCCCCCCCCCCCCCCCC." ) , "$2a$05$CCCCCCCCCCCCCCCCCCCCC.E5YPO9kmyuRGyh0XouQYb4YMJKvyOeW" ) ;
8
+ assert . strictEqual ( bcrypt . hashSync ( "U*U*" , "$2a$05$CCCCCCCCCCCCCCCCCCCCC." ) , "$2a$05$CCCCCCCCCCCCCCCCCCCCC.VGOzA784oUp/Z0DY336zx7pLYAy0lwK" ) ;
9
+ assert . strictEqual ( bcrypt . hashSync ( "U*U*U" , "$2a$05$XXXXXXXXXXXXXXXXXXXXXO" ) , "$2a$05$XXXXXXXXXXXXXXXXXXXXXOAcXxm9kjPGEMsLznoKqmqw7tc8WCx4a" ) ;
10
+ assert . strictEqual ( bcrypt . hashSync ( "" , "$2a$05$CCCCCCCCCCCCCCCCCCCCC." ) , "$2a$05$CCCCCCCCCCCCCCCCCCCCC.7uG0VCzI2bS7j6ymqJi9CdcdxiRTWNy" ) ;
11
+ assert . strictEqual ( bcrypt . hashSync ( "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" , "$2a$05$abcdefghijklmnopqrstuu" ) , "$2a$05$abcdefghijklmnopqrstuu5s2v8.iXieOjg/.AySBTTZIIVFJeBui" ) ;
12
+ assert . done ( ) ;
13
+ } ,
14
+ test_long_passwords : function ( assert ) {
15
+ // bcrypt wrap-around bug in $2a$
16
+ assert . strictEqual ( bcrypt . hashSync ( "012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234" , "$2a$05$CCCCCCCCCCCCCCCCCCCCC." ) , "$2a$05$CCCCCCCCCCCCCCCCCCCCC.6.O1dLNbjod2uo0DVcW.jHucKbPDdHS" ) ;
17
+ assert . strictEqual ( bcrypt . hashSync ( "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345" , "$2a$05$CCCCCCCCCCCCCCCCCCCCC." ) , "$2a$05$CCCCCCCCCCCCCCCCCCCCC.6.O1dLNbjod2uo0DVcW.jHucKbPDdHS" ) ;
18
+ assert . done ( ) ;
19
+ } ,
20
+ test_shorten_salt_to_128_bits : function ( assert ) {
21
+ assert . strictEqual ( bcrypt . hashSync ( "test" , "$2a$10$1234567899123456789012" ) , "$2a$10$123456789912345678901u.OtL1A1eGK5wmvBKUDYKvuVKI7h2XBu" ) ;
22
+ assert . strictEqual ( bcrypt . hashSync ( "U*U*" , "$2a$05$CCCCCCCCCCCCCCCCCCCCCh" ) , "$2a$05$CCCCCCCCCCCCCCCCCCCCCeUQ7VjYZ2hd4bLYZdhuPpZMUpEUJDw1S" ) ;
23
+ assert . strictEqual ( bcrypt . hashSync ( "U*U*" , "$2a$05$CCCCCCCCCCCCCCCCCCCCCM" ) , "$2a$05$CCCCCCCCCCCCCCCCCCCCC.VGOzA784oUp/Z0DY336zx7pLYAy0lwK" ) ;
24
+ assert . strictEqual ( bcrypt . hashSync ( "U*U*" , "$2a$05$CCCCCCCCCCCCCCCCCCCCCA" ) , "$2a$05$CCCCCCCCCCCCCCCCCCCCC.VGOzA784oUp/Z0DY336zx7pLYAy0lwK" ) ;
25
+ assert . done ( ) ;
26
+ }
27
+ }
0 commit comments