Change pubkey representation to hex instead of base64

pull/6/head
sachaaaaa 7 years ago
parent cf8afb167e
commit 8f33419b52

@ -645,7 +645,7 @@
validateNumber() { validateNumber() {
if (this.isPrivate()) { if (this.isPrivate()) {
if (StringView.base64ToBytes(this.id).byteLength == 33) if (this.id.length == (33 * 2)) // 33 bytes in hex
{ {
this.set({ id: this.id }); this.set({ id: this.id });
return null; return null;

@ -173,7 +173,7 @@
}, },
maybeNumber(number) { maybeNumber(number) {
return number.replace(/[\s]*/g, '').match(/^[0-9a-zA-Z\/+]+$/); return number.replace(/[\s]*/g, '').match(/^[0-9a-fA-F]+$/); // hex representation
}, },
}); });
})(); })();

@ -169,7 +169,7 @@
selectAContact: i18n('selectAContact'), selectAContact: i18n('selectAContact'),
searchForPeopleOrGroups: i18n('searchForPeopleOrGroups'), searchForPeopleOrGroups: i18n('searchForPeopleOrGroups'),
settings: i18n('settings'), settings: i18n('settings'),
identityKey: StringView.bytesToBase64(new Uint8Array(identityKey)) identityKey: StringView.arrayBufferToHex(identityKey)
}; };
}, },
events: { events: {

@ -327,7 +327,7 @@
// update our own identity key, which may have changed // update our own identity key, which may have changed
// if we're relinking after a reinstall on the master device // if we're relinking after a reinstall on the master device
const pubKeyString = textsecure.MessageReceiver.arrayBufferToStringBase64(identityKeyPair.pubKey); const pubKeyString = StringView.arrayBufferToHex(identityKeyPair.pubKey);
textsecure.storage.protocol.saveIdentityWithAttributes(pubKeyString, { textsecure.storage.protocol.saveIdentityWithAttributes(pubKeyString, {
id: pubKeyString, id: pubKeyString,

@ -98,5 +98,9 @@
} }
return sB64Enc.replace(/A(?=A$|$)/g, '='); return sB64Enc.replace(/A(?=A$|$)/g, '=');
}, },
arrayBufferToHex(aArrayBuffer) {
return Array.prototype.map.call(new Uint8Array(aArrayBuffer), x => ('00' + x.toString(16)).slice(-2)).join('');
},
}; };
})(); })();

Loading…
Cancel
Save