var publicKey = openpgp.key.readArmored(data);
var publicKeyPacket = publicKey.keys[0].primaryKey;
if (publicKeyPacket != null) {
strength=getBitLength(publicKeyPacket));
}
getBitLength: function(publicKeyPacket) {
var result = -1;
if (publicKeyPacket.mpi.length > 0) {
result = (publicKeyPacket.mpi[0].byteLength() * 8);
}
return result;
}
W dniu 2015-02-26 13:04, Barry de Graaff napisał(a):
> Hi Folks,
>
> What is the way to get the public key length using openpgp.key.readArmored
>
> I have this code:
>
> var publicKeys = openpgp.key.readArmored(pubkey);
> console.log(publicKeys);
> //is a key object
>
> userid = publicKeys.keys[0].users[0].userId.userid;
>
> How do I get the Public Key length (1024, 4096 etc)??
>
> The answer may be somewhere in here:
> https://github.com/openpgpjs/openpgpjs/blob/master/src/packet/public_key.js
>
> /**
> * Returns bit size of key
> * @return {int} Number of bits
> */
> PublicKey.prototype.getBitSize = function () {
> return this.mpi[0].byteLength() * 8;
> };
>
> Not sure how to invoke this though,
>
> What am I missing?
>
> Thanks
>
> Barry
>
> _______________________________________________
>
> http://openpgpjs.org [1]
> Subscribe/unsubscribe: http://list.openpgpjs.org [2]
Links:
------
[1] http://openpgpjs.org
[2] http://list.openpgpjs.org
_______________________________________________
http://openpgpjs.org
Subscribe/unsubscribe: http://list.openpgpjs.org