/// 加密訊息實體
/// 包含 round 值和加密後的內容
class EncryptedMessage {
  final int round;    // 金鑰輪換 round 值
  final String data;  // Base64 編碼的加密內容

  const EncryptedMessage({
    required this.round,
    required this.data,
  });

  /// 從 JSON 創建
  factory EncryptedMessage.fromJson(Map<String, dynamic> json) {
    return EncryptedMessage(
      round: json['round'] as int,
      data: json['data'] as String,
    );
  }

  /// 轉換為 JSON
  Map<String, dynamic> toJson() {
    return {
      'round': round,
      'data': data,
    };
  }

  @override
  bool operator ==(Object other) {
    if (identical(this, other)) return true;
    return other is EncryptedMessage &&
        other.round == round &&
        other.data == data;
  }

  @override
  int get hashCode => Object.hash(round, data);
}

