mirror of
https://github.com/mtan93/homebridge.git
synced 2026-03-27 05:13:10 +00:00
init design
This commit is contained in:
18
lib/util/mac.js
Normal file
18
lib/util/mac.js
Normal file
@@ -0,0 +1,18 @@
|
||||
var crypto = require('crypto');
|
||||
|
||||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
generate: generate
|
||||
}
|
||||
|
||||
function generate(data) {
|
||||
var sha1sum = crypto.createHash('sha1');
|
||||
sha1sum.update(data);
|
||||
var s = sha1sum.digest('hex');
|
||||
var i = -1;
|
||||
return 'xx:xx:xx:xx:xx:xx'.replace(/[x]/g, function(c) {
|
||||
i += 1;
|
||||
return s[i];
|
||||
}).toUpperCase();
|
||||
};
|
||||
Reference in New Issue
Block a user