So I copied an AES algorithm from this AES Encrypt String in VB.NET I use the second answer but I have an error in the decryption part. It says expression expected {"=="}
in the Dim ivct = ciphertext.Split({"=="}, StringSplitOptions.None)
part. How do I solve this?
Asked
Active
Viewed 399 times
0

Aluan Haddad
- 29,886
- 8
- 72
- 84

Rak
- 139
- 5
- 20
-
i tried it on 3.5, 4.0 and 4.6...option strict on and off...its valid syntax – Ctznkane525 Feb 07 '18 at 02:10
-
can you solve my problem? – Rak Feb 07 '18 at 02:11
-
1@Ctznkane525, it's not a .NET version issue but a VB version issue. What version of VB.NET are you using? That code is valid in recent versions but in older ones you would need this: `Dim ivct = ciphertext.Split(New String() {"=="}, StringSplitOptions.None)`. – jmcilhinney Feb 07 '18 at 02:12
-
@jmcilhinney - can you elaborate on this...the version of vb would be tied to the framework...do you instead mean the version of visual studio? – Ctznkane525 Feb 07 '18 at 02:34
-
"the version of vb would be tied to the framework". No it wouldn't. VB 2005 can target .NET 2.0, VB 2017 can target .NET 2.0 and so can every version of VB in between. The issue here is one of VB syntax, so it's a VB issue, not a .NET issue. As far as .NET is concerned, all it cares about is that the first argument passed to `String.Split` is a `String` array. What can validly represent a `String` array in code is wholly dependent on the VB version. The original code is valid in VB 2017 whether you're targeting .NET 2.0 or .NET 4.7.2 but it is never valid in VB 2005. – jmcilhinney Feb 07 '18 at 03:21
-
string.split requires a `char` type as the parameter. If you want to split the string using `==` as the delimiter, try `Dim ivct = Split(ciphertext, "==", StringSplitOptions.None)`. If you want to use "==" including quotes, try """==""" instead. – David Wilson Feb 07 '18 at 19:20