You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
590 B
22 lines
590 B
var inherits = require('inherits');
|
|
|
|
var 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) {
|
|
var buf = DEREncoder.prototype.encode.call(this, data);
|
|
|
|
var p = buf.toString('base64');
|
|
var out = [ '-----BEGIN ' + options.label + '-----' ];
|
|
for (var i = 0; i < p.length; i += 64)
|
|
out.push(p.slice(i, i + 64));
|
|
out.push('-----END ' + options.label + '-----');
|
|
return out.join('\n');
|
|
};
|