File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 652652 }
653653 }
654654
655+ function _stringToBytes ( str ) {
656+ var ch , st , re = [ ] ;
657+ for ( var i = 0 ; i < str . length ; i ++ ) {
658+ ch = str . charCodeAt ( i ) ;
659+ st = [ ] ;
660+ do {
661+ st . push ( ch & 0xFF ) ;
662+ ch = ch >> 8 ;
663+ } while ( ch ) ;
664+ re = re . concat ( st . reverse ( ) ) ;
665+ }
666+ return re ;
667+ }
668+
655669 /**
656670 * Internally hashes a string.
657671 * @param {string } s String to hash
689703 var real_salt = salt . substring ( offset + 3 , offset + 25 ) ;
690704 s += minor >= 'a' ? "\000" : "" ;
691705
692- var buf = new Buffer ( s ) ; // TODO (dcode): What is this good for? Getting bytes?
693- var passwordb = [ ] ;
706+ var passwordb = _stringToBytes ( s ) ;
694707 var saltb = [ ] ;
695- for ( var r = 0 ; r < buf . length ; r ++ ) {
696- passwordb . push ( buf [ r ] ) ;
697- }
698708 saltb = base64 . decode ( real_salt , BCRYPT_SALT_LEN ) ;
699709
700710 /**
You can’t perform that action at this time.
0 commit comments