import 'dart:convert'; import "package:pointycastle/export.dart"; import '/utils/encryption/crypto_utils.dart'; class Friend{ String id; String userId; String friendId; String friendIdDecrypted; String acceptedAt; Friend({ required this.id, required this.userId, required this.friendId, required this.friendIdDecrypted, required this.acceptedAt, }); factory Friend.fromJson(Map json, RSAPrivateKey privKey) { var friendIdDecrypted = CryptoUtils.rsaDecrypt( base64.decode(json['friend_id']), privKey, ); return Friend( id: json['id'], userId: json['user_id'], friendId: json['friend_id'], friendIdDecrypted: String.fromCharCodes(friendIdDecrypted), acceptedAt: json['accepted_at'], ); } @override String toString() { return ''' id: $id userId: $userId, friendId: $friendId, friendIdDecrypted: $friendIdDecrypted, accepted_at: $acceptedAt, '''; } Map toMap() { return { 'id': id, 'user_id': userId, 'friend_id': friendId, 'friend_id_decrypted': friendIdDecrypted, 'accepted_at': acceptedAt, }; } }