@@ -423,7 +423,8 @@ public virtual string EncodeData(ReadOnlySpan<byte> data, Bech32EncodingType enc
423
423
if ( SquashBytes )
424
424
data = ByteSquasher ( data , 8 , 5 ) . AsSpan ( ) ;
425
425
#else
426
- data = ByteSquasher ( data , 8 , 5 ) ;
426
+ if ( SquashBytes )
427
+ data = ByteSquasher ( data , offset , count , 8 , 5 ) ;
427
428
#endif
428
429
429
430
#if HAS_SPAN
@@ -561,7 +562,11 @@ protected virtual byte[] DecodeDataCore(string encoded, out Bech32EncodingType e
561
562
#endif
562
563
if ( SquashBytes )
563
564
{
565
+ #if HAS_SPAN
564
566
arr = ByteSquasher ( arr , 5 , 8 ) ;
567
+ #else
568
+ arr = ByteSquasher ( arr , 0 , arr . Length , 5 , 8 ) ;
569
+ #endif
565
570
if ( arr is null )
566
571
throw new FormatException ( "Invalid squashed bech32" ) ;
567
572
}
@@ -570,15 +575,18 @@ protected virtual byte[] DecodeDataCore(string encoded, out Bech32EncodingType e
570
575
#if HAS_SPAN
571
576
private static byte [ ] ByteSquasher ( ReadOnlySpan < byte > input , int inputWidth , int outputWidth )
572
577
#else
573
- private static byte [ ] ByteSquasher ( byte [ ] input , int inputWidth , int outputWidth )
578
+ private static byte [ ] ByteSquasher ( byte [ ] input , int offset , int count , int inputWidth , int outputWidth )
574
579
#endif
575
580
{
576
581
var bitstash = 0 ;
577
582
var accumulator = 0 ;
578
583
var output = new List < byte > ( ) ;
579
584
var maxOutputValue = ( 1 << outputWidth ) - 1 ;
580
-
585
+ #if HAS_SPAN
581
586
for ( var i = 0 ; i < input . Length ; i ++ )
587
+ #else
588
+ for ( var i = offset ; i < count ; i ++ )
589
+ #endif
582
590
{
583
591
var c = input [ i ] ;
584
592
if ( c >> inputWidth != 0 )
0 commit comments