mirror of
https://github.com/crazy-max/ghaction-import-gpg.git
synced 2024-11-30 00:40:55 -05:00
23 lines
614 B
JavaScript
23 lines
614 B
JavaScript
'use strict';
|
|
|
|
const inherits = require('inherits');
|
|
|
|
const DEREncoder = require('./der');
|
|
|
|
function PEMEncoder(entity) {
|
|
DEREncoder.call(this, entity);
|
|
this.enc = 'pem';
|
|
}
|
|
inherits(PEMEncoder, DEREncoder);
|
|
module.exports = PEMEncoder;
|
|
|
|
PEMEncoder.prototype.encode = function encode(data, options) {
|
|
const buf = DEREncoder.prototype.encode.call(this, data);
|
|
|
|
const p = buf.toString('base64');
|
|
const out = [ '-----BEGIN ' + options.label + '-----' ];
|
|
for (let i = 0; i < p.length; i += 64)
|
|
out.push(p.slice(i, i + 64));
|
|
out.push('-----END ' + options.label + '-----');
|
|
return out.join('\n');
|
|
};
|