123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
- using System;
- using System.IO;
- using System.Text;
- namespace Org.BouncyCastle.Utilities.Encoders
- {
-
-
-
- public sealed class Hex
- {
- private static readonly IEncoder encoder = new HexEncoder();
- private Hex()
- {
- }
- public static string ToHexString(
- byte[] data)
- {
- return ToHexString(data, 0, data.Length);
- }
- public static string ToHexString(
- byte[] data,
- int off,
- int length)
- {
- byte[] hex = Encode(data, off, length);
- return Strings.FromAsciiByteArray(hex);
- }
-
- public static byte[] Encode(
- byte[] data)
- {
- return Encode(data, 0, data.Length);
- }
-
- public static byte[] Encode(
- byte[] data,
- int off,
- int length)
- {
- MemoryStream bOut = new MemoryStream(length * 2);
- encoder.Encode(data, off, length, bOut);
- return bOut.ToArray();
- }
-
- public static int Encode(
- byte[] data,
- Stream outStream)
- {
- return encoder.Encode(data, 0, data.Length, outStream);
- }
-
- public static int Encode(
- byte[] data,
- int off,
- int length,
- Stream outStream)
- {
- return encoder.Encode(data, off, length, outStream);
- }
-
- public static byte[] Decode(
- byte[] data)
- {
- MemoryStream bOut = new MemoryStream((data.Length + 1) / 2);
- encoder.Decode(data, 0, data.Length, bOut);
- return bOut.ToArray();
- }
-
- public static byte[] Decode(
- string data)
- {
- MemoryStream bOut = new MemoryStream((data.Length + 1) / 2);
- encoder.DecodeString(data, bOut);
- return bOut.ToArray();
- }
-
- public static int Decode(
- string data,
- Stream outStream)
- {
- return encoder.DecodeString(data, outStream);
- }
- }
- }
- #endif
|