14 lines
338 B
JavaScript
14 lines
338 B
JavaScript
|
'use strict';
|
||
|
|
||
|
var fs = require('fs');
|
||
|
var path = require('path');
|
||
|
|
||
|
function convert(name) {
|
||
|
var ext = path.extname(name);
|
||
|
var csr = fs.readFileSync(name, 'ascii').replace(/\s\+/g, '');
|
||
|
var bin = Buffer.from(csr, 'hex');
|
||
|
fs.writeFileSync(name.replace(new RegExp('\\' + ext + '$'), '') + '.bin', bin);
|
||
|
}
|
||
|
|
||
|
convert(process.argv[2]);
|