mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Add method to get hexadecimal printout of a byte array.
This commit is contained in:
42
DiscImageChef.DiscImages/CHD.cs
Normal file
42
DiscImageChef.DiscImages/CHD.cs
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
// /***************************************************************************
|
||||||
|
// The Disc Image Chef
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Filename : CHD.cs
|
||||||
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||||
|
//
|
||||||
|
// Component : Component
|
||||||
|
//
|
||||||
|
// --[ Description ] ----------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Description
|
||||||
|
//
|
||||||
|
// --[ License ] --------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// This library is free software; you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Lesser General Public License as
|
||||||
|
// published by the Free Software Foundation; either version 2.1 of the
|
||||||
|
// License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This library is distributed in the hope that it will be useful, but
|
||||||
|
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
// Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public
|
||||||
|
// License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// Copyright © 2011-2016 Natalia Portillo
|
||||||
|
// ****************************************************************************/
|
||||||
|
using System;
|
||||||
|
namespace DiscImageChef.DiscImages
|
||||||
|
{
|
||||||
|
public class CHD
|
||||||
|
{
|
||||||
|
public CHD()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -25,6 +25,7 @@
|
|||||||
// ****************************************************************************/
|
// ****************************************************************************/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
namespace DiscImageChef
|
namespace DiscImageChef
|
||||||
{
|
{
|
||||||
@@ -61,6 +62,20 @@ namespace DiscImageChef
|
|||||||
|
|
||||||
Array.Copy(destinationArray, 0, destinationArray, copyLength, destinationArray.Length - copyLength);
|
Array.Copy(destinationArray, 0, destinationArray, copyLength, destinationArray.Length - copyLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string ByteArrayToHex(byte[] array)
|
||||||
|
{
|
||||||
|
return ByteArrayToHex(array, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string ByteArrayToHex(byte[] array, bool upper)
|
||||||
|
{
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
for(long i = 0; i < array.LongLength; i++)
|
||||||
|
sb.AppendFormat("{0:x2}", array[i]);
|
||||||
|
|
||||||
|
return upper ? sb.ToString().ToUpper() : sb.ToString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user