I think it is better to have symmetric names, if you have getText then the corresponding function should be setText, with the corresponding getBinary and setBinary. But I'm not sure what getBinary should do with text data. 

I don't like getLiteralData because it exposes an implementation detail (the internal representation) of the literalData object. 

----- Original Message -----

| From: "Thomas Oberndörfer" <notifications@github.com>
| To: "openpgpjs/openpgpjs" <openpgpjs@noreply.github.com>
| Cc: "Robert Nelson" <robertn@the-nelsons.org>
| Sent: Saturday, December 7, 2013 2:14:04 PM
| Subject: Re: [openpgpjs] Merge signature changes from master (#137)

| In src/packet/literal.js:
| >    /**
| >     * Get the byte sequence representing the literal packet data
| >     * @returns {String} A sequence of bytes
| >     */
| >    this.getBytes = function() {
| > -    var bytes = this.data;
| > -    switch (this.format) {
| > -      case 'utf8':
| > -        bytes = bytes.replace(/\n/g, '\r\n');
| > -        bytes = util.encode_utf8(bytes);
| > -        break;
| > -      case 'text':
| > -        bytes = bytes.replace(/\n/g, '\r\n');
| > -        break;
| > -    }
| > -    return bytes;
| > +    return this.format == 'utf8' ? util.encode_utf8(this.data) :
| > this.data;
| >    }
| >

| Sounds great!

| Not sure about the method layout. What you have sounds good for
| literalDataPacket.
| But Message and CleartextMessage is on a different abstraction layer.
| So setText for a message is currently openpgp.message.fromText, which means
| you create a new literaldata packet, put it in a packetlist and this forms
| the new message.
| setBytes, and getBytes feels also to low-level for me for Message and
| CleartextMessage
| How about openpgp.message.fromBinary similar to fromText and it returns a new
| message
| object? getBytes could stay getLiteralData.

| —
| Reply to this email directly or view it on GitHub .