Skip to content

Commit 57fff65

Browse files
committed
Alias exports for Auth module
1 parent 7c792a5 commit 57fff65

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

lib/Auth.js

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
var Buffer = require('buffer').Buffer;
22
var crypto = require('crypto');
3+
var Auth = exports;
34

45
function sha1(msg) {
56
var hash = crypto.createHash('sha1');
67
hash.update(msg);
78
// hash.digest() does not output buffers yet
89
return hash.digest('binary');
910
};
10-
exports.sha1 = sha1;
11+
Auth.sha1 = sha1;
1112

1213
function xor(a, b) {
1314
a = new Buffer(a, 'binary');
@@ -18,9 +19,9 @@ function xor(a, b) {
1819
}
1920
return result;
2021
};
21-
exports.xor = xor;
22+
Auth.xor = xor;
2223

23-
exports.token = function(password, scramble) {
24+
Auth.token = function(password, scramble) {
2425
if (!password) {
2526
return new Buffer(0);
2627
}
@@ -33,7 +34,7 @@ exports.token = function(password, scramble) {
3334

3435
// This is a port of sql/password.c:hash_password which needs to be used for
3536
// pre-4.1 passwords.
36-
exports.hashPassword = function(password) {
37+
Auth.hashPassword = function(password) {
3738
var nr = [0x5030, 0x5735],
3839
add = 7,
3940
nr2 = [0x1234, 0x5671],
@@ -68,7 +69,7 @@ exports.hashPassword = function(password) {
6869
return result;
6970
};
7071

71-
exports.randomInit = function(seed1, seed2) {
72+
Auth.randomInit = function(seed1, seed2) {
7273
return {
7374
max_value: 0x3FFFFFFF,
7475
max_value_dbl: 0x3FFFFFFF,
@@ -77,14 +78,14 @@ exports.randomInit = function(seed1, seed2) {
7778
};
7879
};
7980

80-
exports.myRnd = function(r){
81+
Auth.myRnd = function(r){
8182
r.seed1 = (r.seed1 * 3 + r.seed2) % r.max_value;
8283
r.seed2 = (r.seed1 + r.seed2 + 33) % r.max_value;
8384

8485
return r.seed1 / r.max_value_dbl;
8586
};
8687

87-
exports.scramble323 = function(message, password) {
88+
Auth.scramble323 = function(message, password) {
8889
var to = new Buffer(8),
8990
hashPass = this.hashPassword(password),
9091
hashMessage = this.hashPassword(message.slice(0, 8)),
@@ -104,7 +105,7 @@ exports.scramble323 = function(message, password) {
104105
return to;
105106
};
106107

107-
exports.fmt32 = function(x){
108+
Auth.fmt32 = function(x){
108109
var a = x[0].toString(16),
109110
b = x[1].toString(16);
110111

@@ -117,18 +118,18 @@ exports.fmt32 = function(x){
117118
return '' + a + '/' + b;
118119
};
119120

120-
exports.xor32 = function(a,b){
121+
Auth.xor32 = function(a,b){
121122
return [a[0] ^ b[0], a[1] ^ b[1]];
122123
};
123124

124-
exports.add32 = function(a,b){
125+
Auth.add32 = function(a,b){
125126
var w1 = a[1] + b[1],
126127
w2 = a[0] + b[0] + ((w1 & 0xFFFF0000) >> 16);
127128

128129
return [w2 & 0xFFFF, w1 & 0xFFFF];
129130
};
130131

131-
exports.mul32 = function(a,b){
132+
Auth.mul32 = function(a,b){
132133
// based on this example of multiplying 32b ints using 16b
133134
// http://www.dsprelated.com/showmessage/89790/1.php
134135
var w1 = a[1] * b[1],
@@ -137,26 +138,26 @@ exports.mul32 = function(a,b){
137138
return [w2 & 0xFFFF, w1 & 0xFFFF];
138139
};
139140

140-
exports.and32 = function(a,b){
141+
Auth.and32 = function(a,b){
141142
return [a[0] & b[0], a[1] & b[1]];
142143
};
143144

144-
exports.shl32 = function(a,b){
145+
Auth.shl32 = function(a,b){
145146
// assume b is 16 or less
146147
var w1 = a[1] << b,
147148
w2 = (a[0] << b) | ((w1 & 0xFFFF0000) >> 16);
148149

149150
return [w2 & 0xFFFF, w1 & 0xFFFF];
150151
};
151152

152-
exports.int31Write = function(buffer, number, offset) {
153+
Auth.int31Write = function(buffer, number, offset) {
153154
buffer[offset] = (number[0] >> 8) & 0x7F;
154155
buffer[offset + 1] = (number[0]) & 0xFF;
155156
buffer[offset + 2] = (number[1] >> 8) & 0xFF;
156157
buffer[offset + 3] = (number[1]) & 0xFF;
157158
};
158159

159-
exports.int32Read = function(buffer, offset){
160+
Auth.int32Read = function(buffer, offset){
160161
return (buffer[offset] << 24)
161162
+ (buffer[offset+1] << 16)
162163
+ (buffer[offset+2] << 8)

0 commit comments

Comments
 (0)