diff --git a/src/encoding/armor.js b/src/encoding/armor.js index 2bfe0fe5..fd5efdab 100644 --- a/src/encoding/armor.js +++ b/src/encoding/armor.js @@ -16,7 +16,7 @@ // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA import { transform as streamTransform, transformPair as streamTransformPair, getReader as streamGetReader, getWriter as streamGetWriter, isArrayStream, readToEnd as streamReadToEnd, passiveClone as streamPassiveClone } from '@openpgp/web-stream-tools'; -import * as base64 from './base64'; +import { encode as encodeBase64, decode as decodeBase64 } from './base64'; import enums from '../enums'; import util from '../util'; import defaultConfig from '../config'; @@ -115,7 +115,7 @@ function addheader(customComment, config) { */ function getCheckSum(data) { const crc = createcrc24(data); - return base64.encode(crc); + return encodeBase64(crc); } // https://create.stephan-brumme.com/crc32/#slicing-by-8-overview @@ -239,7 +239,7 @@ export function unarmor(input) { let headersDone; let text = []; let textDone; - const data = base64.decode(streamTransformPair(input, async (readable, writable) => { + const data = decodeBase64(streamTransformPair(input, async (readable, writable) => { const reader = streamGetReader(readable); try { while (true) { @@ -357,14 +357,14 @@ export function armor(messageType, body, partIndex, partTotal, customComment, em case enums.armor.multipartSection: result.push('-----BEGIN PGP MESSAGE, PART ' + partIndex + '/' + partTotal + '-----\n'); result.push(addheader(customComment, config)); - result.push(base64.encode(body)); + result.push(encodeBase64(body)); maybeBodyClone && result.push('=', getCheckSum(maybeBodyClone)); result.push('-----END PGP MESSAGE, PART ' + partIndex + '/' + partTotal + '-----\n'); break; case enums.armor.multipartLast: result.push('-----BEGIN PGP MESSAGE, PART ' + partIndex + '-----\n'); result.push(addheader(customComment, config)); - result.push(base64.encode(body)); + result.push(encodeBase64(body)); maybeBodyClone && result.push('=', getCheckSum(maybeBodyClone)); result.push('-----END PGP MESSAGE, PART ' + partIndex + '-----\n'); break; @@ -374,35 +374,35 @@ export function armor(messageType, body, partIndex, partTotal, customComment, em result.push(text.replace(/^-/mg, '- -')); result.push('\n-----BEGIN PGP SIGNATURE-----\n'); result.push(addheader(customComment, config)); - result.push(base64.encode(body)); + result.push(encodeBase64(body)); maybeBodyClone && result.push('=', getCheckSum(maybeBodyClone)); result.push('-----END PGP SIGNATURE-----\n'); break; case enums.armor.message: result.push('-----BEGIN PGP MESSAGE-----\n'); result.push(addheader(customComment, config)); - result.push(base64.encode(body)); + result.push(encodeBase64(body)); maybeBodyClone && result.push('=', getCheckSum(maybeBodyClone)); result.push('-----END PGP MESSAGE-----\n'); break; case enums.armor.publicKey: result.push('-----BEGIN PGP PUBLIC KEY BLOCK-----\n'); result.push(addheader(customComment, config)); - result.push(base64.encode(body)); + result.push(encodeBase64(body)); maybeBodyClone && result.push('=', getCheckSum(maybeBodyClone)); result.push('-----END PGP PUBLIC KEY BLOCK-----\n'); break; case enums.armor.privateKey: result.push('-----BEGIN PGP PRIVATE KEY BLOCK-----\n'); result.push(addheader(customComment, config)); - result.push(base64.encode(body)); + result.push(encodeBase64(body)); maybeBodyClone && result.push('=', getCheckSum(maybeBodyClone)); result.push('-----END PGP PRIVATE KEY BLOCK-----\n'); break; case enums.armor.signature: result.push('-----BEGIN PGP SIGNATURE-----\n'); result.push(addheader(customComment, config)); - result.push(base64.encode(body)); + result.push(encodeBase64(body)); maybeBodyClone && result.push('=', getCheckSum(maybeBodyClone)); result.push('-----END PGP SIGNATURE-----\n'); break;