mirror of
https://github.com/openpgpjs/openpgpjs.git
synced 2026-02-28 14:03:26 +00:00
Working towards key generation, started cleanup of config, changing
armor api slightly to pass in whether or not to show version string, not entirely happy with current solution.
This commit is contained in:
@@ -80,13 +80,13 @@ function get_type(text) {
|
||||
* @version 2011-12-16
|
||||
* @returns {String} The header information
|
||||
*/
|
||||
function armor_addheader() {
|
||||
function armor_addheader(options) {
|
||||
var result = "";
|
||||
if (openpgp.config.config.show_version) {
|
||||
result += "Version: " + openpgp.config.versionstring + '\r\n';
|
||||
if (options.show_version) {
|
||||
result += "Version: " + options.versionstring + '\r\n';
|
||||
}
|
||||
if (openpgp.config.config.show_comment) {
|
||||
result += "Comment: " + openpgp.config.commentstring + '\r\n';
|
||||
if (options.show_comment) {
|
||||
result += "Comment: " + options.commentstring + '\r\n';
|
||||
}
|
||||
result += '\r\n';
|
||||
return result;
|
||||
@@ -262,19 +262,19 @@ function dearmor(text) {
|
||||
* @param {Integer} parttotal
|
||||
* @returns {String} Armored text
|
||||
*/
|
||||
function armor(messagetype, data, partindex, parttotal) {
|
||||
function armor(messagetype, data, options, partindex, parttotal) {
|
||||
var result = "";
|
||||
switch (messagetype) {
|
||||
case 0:
|
||||
result += "-----BEGIN PGP MESSAGE, PART " + partindex + "/" + parttotal + "-----\r\n";
|
||||
result += armor_addheader();
|
||||
result += armor_addheader(options);
|
||||
result += base64.encode(data);
|
||||
result += "\r\n=" + getCheckSum(data) + "\r\n";
|
||||
result += "-----END PGP MESSAGE, PART " + partindex + "/" + parttotal + "-----\r\n";
|
||||
break;
|
||||
case 1:
|
||||
result += "-----BEGIN PGP MESSAGE, PART " + partindex + "-----\r\n";
|
||||
result += armor_addheader();
|
||||
result += armor_addheader(options);
|
||||
result += base64.encode(data);
|
||||
result += "\r\n=" + getCheckSum(data) + "\r\n";
|
||||
result += "-----END PGP MESSAGE, PART " + partindex + "-----\r\n";
|
||||
@@ -283,28 +283,28 @@ function armor(messagetype, data, partindex, parttotal) {
|
||||
result += "\r\n-----BEGIN PGP SIGNED MESSAGE-----\r\nHash: " + data.hash + "\r\n\r\n";
|
||||
result += data.text.replace(/\n-/g, "\n- -");
|
||||
result += "\r\n-----BEGIN PGP SIGNATURE-----\r\n";
|
||||
result += armor_addheader();
|
||||
result += armor_addheader(options);
|
||||
result += base64.encode(data.openpgp);
|
||||
result += "\r\n=" + getCheckSum(data.openpgp) + "\r\n";
|
||||
result += "-----END PGP SIGNATURE-----\r\n";
|
||||
break;
|
||||
case 3:
|
||||
result += "-----BEGIN PGP MESSAGE-----\r\n";
|
||||
result += armor_addheader();
|
||||
result += armor_addheader(options);
|
||||
result += base64.encode(data);
|
||||
result += "\r\n=" + getCheckSum(data) + "\r\n";
|
||||
result += "-----END PGP MESSAGE-----\r\n";
|
||||
break;
|
||||
case 4:
|
||||
result += "-----BEGIN PGP PUBLIC KEY BLOCK-----\r\n";
|
||||
result += armor_addheader();
|
||||
result += armor_addheader(options);
|
||||
result += base64.encode(data);
|
||||
result += "\r\n=" + getCheckSum(data) + "\r\n";
|
||||
result += "-----END PGP PUBLIC KEY BLOCK-----\r\n\r\n";
|
||||
break;
|
||||
case 5:
|
||||
result += "-----BEGIN PGP PRIVATE KEY BLOCK-----\r\n";
|
||||
result += armor_addheader();
|
||||
result += armor_addheader(options);
|
||||
result += base64.encode(data);
|
||||
result += "\r\n=" + getCheckSum(data) + "\r\n";
|
||||
result += "-----END PGP PRIVATE KEY BLOCK-----\r\n";
|
||||
|
||||
Reference in New Issue
Block a user