Skip to content

Commit dd09698

Browse files
committed
commit all local changes
1 parent 0f93e4c commit dd09698

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

index.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ var os = require('os');
1414
var crypto = require('crypto');
1515
var getmac = require('getmac');
1616

17-
//options
18-
exports.options = {
17+
var defaults = {
1918
encryption: 'md5', //encryption algorithm
2019
encoding: 'hex', //encoding format
2120
keyLength: 20, //default key length
@@ -25,6 +24,14 @@ exports.options = {
2524
secret: undefined //encyption key default to machine id
2625
};
2726

27+
//options
28+
exports.options = defaults;
29+
30+
//restore default settings
31+
exports.restore = function() {
32+
exports.options = defaults;
33+
};
34+
2835

2936
/**
3037
* @function

spec/index.spec.js

+19
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,15 @@ var keygen = require(path.join(__dirname, '..'));
88

99
describe('keygen', function() {
1010
var key;
11+
1112
var data = {
1213
uuid: '123dr34'
1314
};
1415

16+
beforeEach(function() {
17+
keygen.restore();
18+
});
19+
1520
it('should be able to obtain host os details', function(done) {
1621
keygen.os(function(error, os) {
1722

@@ -108,4 +113,18 @@ describe('keygen', function() {
108113
});
109114
});
110115

116+
it('should be able to use different encryption algorithm', function(done) {
117+
118+
keygen.options.encryption = 'sha256';
119+
120+
keygen.generate(data, function(error, _key) {
121+
//assert
122+
expect(error).to.not.exist;
123+
expect(_key).to.exist;
124+
done(error, _key);
125+
});
126+
127+
});
128+
129+
111130
});

0 commit comments

Comments
 (0)