-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using System.Text; | ||
|
||
namespace EfuseManager; | ||
|
||
internal static class TextFormatter | ||
{ | ||
public static string FormatByteArray(byte[] bytes) | ||
{ | ||
var builder = new StringBuilder(); | ||
var linesCount = bytes.Length / 16; | ||
for (int i = 0; i < linesCount; i++) | ||
{ | ||
var startByte = i * 16; | ||
var bl = bytes.AsSpan(startByte, 16); | ||
builder.AppendLine( | ||
$"0x{startByte:x3}: {bl[0]:X2} {bl[1]:X2} {bl[2]:X2} {bl[3]:X2} {bl[4]:X2} {bl[5]:X2} {bl[6]:X2} {bl[7]:X2} {bl[8]:X2} {bl[9]:X2} {bl[10]:X2} {bl[11]:X2} {bl[12]:X2} {bl[13]:X2} {bl[14]:X2} {bl[15]:X2}"); | ||
} | ||
|
||
return builder.ToString(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters