Skip to content

Commit

Permalink
Simplified the slices of spans. (#346)
Browse files Browse the repository at this point in the history
Signed-off-by: AraHaan <[email protected]>
  • Loading branch information
AraHaan authored Dec 7, 2024
1 parent 3b97b2b commit b28c67b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/BlowFish/BlowFish/BlowFishInternal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,8 @@ internal byte[] EncryptCBC(byte[] pt)
internal string DecryptCBC(string ct)
{
ArgumentNullException.ThrowIfNull(ct);
this.IV = HexToByte(ct.AsSpan().Slice(0, 16));
return Encoding.ASCII.GetString(this.DecryptCBC(HexToByte(ct.AsSpan().Slice(16))).Remove((byte)'\0'));
this.IV = HexToByte(ct.AsSpan()[..16]);
return Encoding.ASCII.GetString(this.DecryptCBC(HexToByte(ct.AsSpan()[16..])).Remove((byte)'\0'));
}

internal byte[] DecryptCBC(byte[] ct)
Expand Down Expand Up @@ -494,7 +494,7 @@ private byte[] Crypt_CBC(byte[] text, bool decrypt)

var plainText = text.AsSpan();
byte[]? preblock = null;
var iv = this.initVector.AsSpan().Slice(0, 8);
var iv = this.initVector.AsSpan()[..8];
for (var i = 0; i < plainText.Length; i += 8)
{
var block = plainText.Slice(i, 8);
Expand Down

0 comments on commit b28c67b

Please sign in to comment.