Sorry, the code is:

var openpgp = window.openpgp;
var testPublicKey = sessionStorage.getItem('testPublicKey');
var foundKeys = openpgp.key.readArmored(testPublicKey).keys;

if (!foundKeys || foundKeys.length !== 1) {
    throw new Error("Key not readed, or more than one key");
}

var pubKey = foundKeys[0]; foundKeys = null;

var getFingerprint = function (key) {
    // openpgp.key <- Class
    // key <- Instance received by params
    return key.primaryKey.fingerprint;
};

console.log(getFingerprint(pubKey));


El dom., 13 de dic. de 2015 a la(s) 23:36, Tio Oscar <[email protected]>
escribió:

> You are calling openpgp.key.primaryKey.fingerprint staticly. You have to
> use "primaryKey" property from the instance of the key object.
>
> Test it:
>
> var openpgp = window.openpgp;
> var testPublicKey = sessionStorage.getItem('testPublicKey');
> var foundKeys = openpgp.key.readArmored(testPublicKey).keys;
>
> if (!foundKeys || foundKeys.length !== 1) {
>    var pubKey = foundKeys[0];
>    foundKeys = null;
> }
>
> var getFingerprint = function (key) {
>     // openpgp.key <- Class
>     // key <- Instance received by params
>     return openpgp.key.primaryKey.fingerprint;
> };
>
> console.log(getFingerprint(pubKey));
>
>
>
> El dom., 13 de dic. de 2015 a la(s) 16:26, Andrew <[email protected]>
> escribió:
>
>> (using openpgp1.2/openpgpjs-master/dist/openpgp.js)
>>
>> var openpgp = window.openpgp;
>> var testPublicKey = sessionStorage.getItem('testPublicKey');
>> var pubkey = openpgp.key.readArmored(testPublicKey).keys;
>>
>> var getFingerprint = function (key) {
>>     return openpgp.key.primaryKey.fingerprint;
>>   };
>>
>> console.log(getFingerprint(pubkey));
>>
>> // this returns: TypeError: openpgp.key.primaryKey is undefined
>>
>> // if I do console.log(openpgp.key);
>> //this returns: Object { Key: Key(), readArmored: readArmored(),
>> generate: generate(), getPreferredSymAlgo: getPreferredSymAlgo() }
>>
>> any suggestions?
>>
>> On Sun, Dec 13, 2015 at 6:14 AM, Tio Oscar <[email protected]> wrote:
>>
>>> var getFingerprint = function (key) {
>>>     return key.primaryKey.fingerprint;
>>> };
>>>
>>> El sáb., 12 de dic. de 2015 a la(s) 13:03, Andrew <[email protected]>
>>> escribió:
>>>
>>>> There are two functions in public_key.js - getFingerprint()
>>>> and getKeyId().
>>>> I would like to run the public key through both these functions, any
>>>> idea how?
>>>>
>>>> thanks.
>>>> _______________________________________________
>>>>
>>>> http://openpgpjs.org
>>>> Subscribe/unsubscribe: http://list.openpgpjs.org
>>>
>>>
>>> _______________________________________________
>>>
>>> http://openpgpjs.org
>>> Subscribe/unsubscribe: http://list.openpgpjs.org
>>>
>>
>> _______________________________________________
>>
>> http://openpgpjs.org
>> Subscribe/unsubscribe: http://list.openpgpjs.org
>
>
_______________________________________________

http://openpgpjs.org
Subscribe/unsubscribe: http://list.openpgpjs.org

Reply via email to