-
-
Notifications
You must be signed in to change notification settings - Fork 645
/
Copy pathpemtobin
executable file
·42 lines (35 loc) · 1.09 KB
/
pemtobin
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env node
/*
* pemtobin - convert any PEM to binary file
*
* Copyright (c) 2015-2020 Kenji Urushima ([email protected])
*
* This software is licensed under the terms of the MIT License.
* https://kjur.github.io/jsrsasign/license
*
* The above copyright and license notice shall be
* included in all copies or substantial portions of the Software.
*
* Please use '-h' option for this script usage.
* ---------------------------------------------------------
* DESCRIPTION
* This script converts any PEM to binary file
*
* USAGE
* % pemtobin aaa.pem aaa.bin
*/
var program = require('commander');
var rs = require('jsrsasign');
var rsu = require('jsrsasign-util');
program
.version('0.0.3 (2020-May-31)')
.usage('[options] <input PEM file> <output binary file>')
.description('convert any PEM file to binary')
.parse(process.argv);
if (program.args.length !== 2)
throw "wrong number of arguments";
var inFile = program.args[0];
var outFile = program.args[1];
var pem = rsu.readFile(inFile);
var hex = rs.pemtohex(pem);
rsu.saveFileBinByHex(outFile, hex);