From b28c67bf381037f596c247ba3ef8b185ee1a25f4 Mon Sep 17 00:00:00 2001 From: AraHaan Date: Sat, 7 Dec 2024 10:43:26 -0500 Subject: [PATCH] Simplified the slices of spans. (#346) Signed-off-by: AraHaan --- src/BlowFish/BlowFish/BlowFishInternal.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/BlowFish/BlowFish/BlowFishInternal.cs b/src/BlowFish/BlowFish/BlowFishInternal.cs index 0cf7571..3a117b9 100644 --- a/src/BlowFish/BlowFish/BlowFishInternal.cs +++ b/src/BlowFish/BlowFish/BlowFishInternal.cs @@ -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) @@ -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);