mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-12 18:27:24 +01:00
Add Base64 to customizedata.
This commit is contained in:
parent
bbfdc7fad2
commit
6eb2d9a9d2
1 changed files with 22 additions and 0 deletions
|
|
@ -55,4 +55,26 @@ public unsafe struct CustomizeData : IEquatable< CustomizeData >
|
|||
return HashCode.Combine( *p, p[ 1 ], p[ 2 ], p[ 3 ], p[ 4 ], p[ 5 ], u );
|
||||
}
|
||||
}
|
||||
|
||||
public string WriteBase64()
|
||||
{
|
||||
fixed( byte* ptr = Data )
|
||||
{
|
||||
var data = new ReadOnlySpan< byte >( ptr, Size );
|
||||
return Convert.ToBase64String( data );
|
||||
}
|
||||
}
|
||||
|
||||
public bool LoadBase64( string base64 )
|
||||
{
|
||||
var buffer = stackalloc byte[Size];
|
||||
var span = new Span< byte >( buffer, Size );
|
||||
if( !Convert.TryFromBase64String( base64, span, out var written ) || written != Size )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Read( buffer );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue