mirror of
https://github.com/vishalxl/nostr_console.git
synced 2025-06-08 22:20:11 +02:00
changed name colors a bit; handled case if incoming DM is wrong format
little change of looking up name so one letter names can be looked up
This commit is contained in:
parent
00c990d395
commit
f305437862
@ -422,6 +422,7 @@ class EventData {
|
|||||||
|
|
||||||
String? decryptDirectMessage() {
|
String? decryptDirectMessage() {
|
||||||
int ivIndex = content.indexOf("?iv=");
|
int ivIndex = content.indexOf("?iv=");
|
||||||
|
if( ivIndex > 0) {
|
||||||
var iv = content.substring( ivIndex + 4, content.length);
|
var iv = content.substring( ivIndex + 4, content.length);
|
||||||
var enc_str = content.substring(0, ivIndex);
|
var enc_str = content.substring(0, ivIndex);
|
||||||
|
|
||||||
@ -445,6 +446,10 @@ class EventData {
|
|||||||
|
|
||||||
var decrypted = myPrivateDecrypt( userKey, otherUserPubKey, enc_str, iv); // use bob's privatekey and alic's publickey means bob can read message from alic
|
var decrypted = myPrivateDecrypt( userKey, otherUserPubKey, enc_str, iv); // use bob's privatekey and alic's publickey means bob can read message from alic
|
||||||
return decrypted;
|
return decrypted;
|
||||||
|
} else {
|
||||||
|
if(gDebug > 0) print("Invalid content for dm, could not get ivIndex: $content");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Channel? getChannelForMessage(List<Channel>? listChannel, String messageId) {
|
Channel? getChannelForMessage(List<Channel>? listChannel, String messageId) {
|
||||||
@ -1079,7 +1084,7 @@ String getAuthorName(String pubkey, [int len = 3]) {
|
|||||||
|
|
||||||
// returns full public key(s) for the given username( which can be first few letters of pubkey, or the user name)
|
// returns full public key(s) for the given username( which can be first few letters of pubkey, or the user name)
|
||||||
Set<String> getPublicKeyFromName(String inquiredName) {
|
Set<String> getPublicKeyFromName(String inquiredName) {
|
||||||
if( inquiredName.length < 2) {
|
if( inquiredName.length < 1) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
Set<String> pubkeys = {};
|
Set<String> pubkeys = {};
|
||||||
@ -1094,7 +1099,7 @@ Set<String> getPublicKeyFromName(String inquiredName) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// check public key
|
// check public key
|
||||||
if( inquiredName.length <= pubkey.length) {
|
if( inquiredName.length >= 2 && inquiredName.length <= pubkey.length) {
|
||||||
if( pubkey.substring(0, inquiredName.length) == inquiredName) {
|
if( pubkey.substring(0, inquiredName.length) == inquiredName) {
|
||||||
pubkeys.add(pubkey);
|
pubkeys.add(pubkey);
|
||||||
}
|
}
|
||||||
@ -1521,6 +1526,7 @@ try {
|
|||||||
String myEncrypt( String privateString,
|
String myEncrypt( String privateString,
|
||||||
String publicString,
|
String publicString,
|
||||||
String plainText) {
|
String plainText) {
|
||||||
|
print("private = ${privateString.length} public = ${publicString.length}");
|
||||||
Uint8List uintInputText = convert.Utf8Encoder().convert(plainText);
|
Uint8List uintInputText = convert.Utf8Encoder().convert(plainText);
|
||||||
final encryptedString = myEncryptRaw(privateString, publicString, uintInputText);
|
final encryptedString = myEncryptRaw(privateString, publicString, uintInputText);
|
||||||
return encryptedString;
|
return encryptedString;
|
||||||
|
@ -167,9 +167,9 @@ List<String> nameColorPalette = [brightMagentaColor, brightBlueColor, brightCyan
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Map<String, String> pubkeyColor = { '0': brightMagentaColor, '1': brightMagentaColor,
|
Map<String, String> pubkeyColor = { '0': magentaColor, '1': brightMagentaColor,
|
||||||
'2': brightBlueColor, '3': brightBlueColor,
|
'2': blueColor, '3': brightBlueColor,
|
||||||
'4': brightCyanColor, '5': brightCyanColor,
|
'4': cyanColor, '5': brightCyanColor,
|
||||||
'6': brightGreenColor, '7': brightGreenColor,
|
'6': brightGreenColor, '7': brightGreenColor,
|
||||||
'8': brightYellowColor,'9': brightYellowColor,
|
'8': brightYellowColor,'9': brightYellowColor,
|
||||||
'a': brightRedColor, 'b': brightRedColor,
|
'a': brightRedColor, 'b': brightRedColor,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user