public static string PrettifyCPRMMediaKeyBlock(CPRMMediaKeyBlock?CPRMMKBResponse) { if (CPRMMKBResponse == null) { return(null); } CPRMMediaKeyBlock response = CPRMMKBResponse.Value; var sb = new StringBuilder(); #if DEBUG if (response.Reserved != 0) { sb.AppendFormat("Reserved = 0x{0:X2}", response.Reserved).AppendLine(); } #endif sb.AppendFormat("Total number of CPRM Media Key Blocks available to transfer: {0}", response.TotalPacks). AppendLine(); sb.AppendFormat("CPRM Media Key Blocks in hex follows:"); sb.AppendLine(PrintHex.ByteArrayToHexArrayString(response.MKBPackData, 80)); return(sb.ToString()); }
public static CPRMMediaKeyBlock?DecodeCPRMMediaKeyBlock(byte[] CPRMMKBResponse) { if (CPRMMKBResponse == null) { return(null); } CPRMMediaKeyBlock decoded = new CPRMMediaKeyBlock { MKBPackData = new byte[CPRMMKBResponse.Length - 4], DataLength = BigEndianBitConverter.ToUInt16(CPRMMKBResponse, 0), Reserved = CPRMMKBResponse[2], TotalPacks = CPRMMKBResponse[3] }; Array.Copy(CPRMMKBResponse, 4, decoded.MKBPackData, 0, CPRMMKBResponse.Length - 4); return(decoded); }