當前位置: 首頁>>代碼示例>>C#>>正文


C# ByteBuffer.AppendHex方法代碼示例

本文整理匯總了C#中System.ByteBuffer.AppendHex方法的典型用法代碼示例。如果您正苦於以下問題:C# ByteBuffer.AppendHex方法的具體用法?C# ByteBuffer.AppendHex怎麽用?C# ByteBuffer.AppendHex使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.ByteBuffer的用法示例。


在下文中一共展示了ByteBuffer.AppendHex方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: SignDeferred

 /**
  * Signs a PDF where space was already reserved.
  * @param reader the original PDF
  * @param fieldName the field to sign. It must be the last field
  * @param outs the output PDF
  * @param externalSignatureContainer the signature container doing the actual signing. Only the 
  * method ExternalSignatureContainer.sign is used
  * @throws DocumentException
  * @throws IOException
  * @throws GeneralSecurityException 
  */
 public static void SignDeferred(PdfReader reader, String fieldName, Stream outs, IExternalSignatureContainer externalSignatureContainer) {
     AcroFields af = reader.AcroFields;
     PdfDictionary v = af.GetSignatureDictionary(fieldName);
     if (v == null)
         throw new DocumentException("No field");
     if (!af.SignatureCoversWholeDocument(fieldName))
         throw new DocumentException("Not the last signature");
     PdfArray b = v.GetAsArray(PdfName.BYTERANGE);
     long[] gaps = b.AsLongArray();
     if (b.Size != 4 || gaps[0] != 0)
         throw new DocumentException("Single exclusion space supported");
     IRandomAccessSource readerSource = reader.SafeFile.CreateSourceView();
     Stream rg = new RASInputStream(new RandomAccessSourceFactory().CreateRanged(readerSource, gaps));
     byte[] signedContent = externalSignatureContainer.Sign(rg);
     int spaceAvailable = (int)(gaps[2] - gaps[1]) - 2;
     if ((spaceAvailable & 1) != 0)
         throw new DocumentException("Gap is not a multiple of 2");
     spaceAvailable /= 2;
     if (spaceAvailable < signedContent.Length)
         throw new DocumentException("Not enough space");
     StreamUtil.CopyBytes(readerSource, 0, gaps[1] + 1, outs);
     ByteBuffer bb = new ByteBuffer(spaceAvailable * 2);
     foreach (byte bi in signedContent) {
         bb.AppendHex(bi);
     }
     int remain = (spaceAvailable - signedContent.Length) * 2;
     for (int k = 0; k < remain; ++k) {
         bb.Append((byte)48);
     }
     bb.WriteTo(outs);
     StreamUtil.CopyBytes(readerSource, gaps[2] - 1, gaps[3] + 1, outs);
 }
開發者ID:NelsonSantos,項目名稱:fyiReporting-Android,代碼行數:43,代碼來源:MakeSignature.cs

示例2: ConvertToHex

 private static String ConvertToHex(byte[] bt)
 {
     ByteBuffer buf = new ByteBuffer();
     foreach (byte b in bt) {
         buf.AppendHex(b);
     }
     return PdfEncodings.ConvertToString(buf.ToByteArray(), null).ToUpperInvariant();
 }
開發者ID:medvedttn,項目名稱:itextsharp_mod-src,代碼行數:8,代碼來源:LtvVerification.cs


注:本文中的System.ByteBuffer.AppendHex方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。