old-keypairs.js/convert-from-hex.js

14 lines
338 B
JavaScript
Raw Normal View History

2018-11-16 08:40:07 +00:00
'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]);