Hi, ok i had a file looking like this:
SilkroadR,,321,13,321,Gobi,False,False,False,False,False
SilkroadR,,321,321321,321,Gobi,False,False,False,False,False
SilkroadR,,213,321,231,Gobi,False,False,False,False,False
SilkroadR,,3251325,3215,3251,Gobi,False,False,False,False,False
SilkroadR,,,,,Gobi,False,False,False,False,False
I encrypted it and it looks like this:
Hdgr6oHm47q2SC5AEjqUY9Boi5WfUT5FTfLvMVYLtorgmufM5GiH6wMg12raZ/YpW/OPZ7bL94wbSWiauy59nrEHlJdO3o1voedaWb/XV7lxNzbUURqDgGtkpr6Ex++d0YAA4sCnkB/GcDtuFd+vqF2IJoI3cC+WKPF73zM5eNz6mJd1hjZK+40je7/LbUyU7JQ8nmvBpEy7J391xM5X5dfKlNziYahufdVsxbO8mTAosQcEZ8JtUoJg2ZWjXO8nPqDci8iy/JgBYnd8Z4fpbfwY5jKwTrq2+TW9k/+I2F9PXUT6OzUUTk4tRFfvWVXBFj/C5s60puxaYJQxgzUzKE2yWls4N3qk3TcZBH1kKCB8h0lS69X77mOxJ0ixkOm1a+deaIWXsBfFHq8ej30ShH2WFf09iAr3
Ok, thats what i wanted, i used to load my accounts like how it looked before the encrypting with this code:
Dim iCount As Integer = CInt("0")
Accounts = New List(Of Account)
My.Forms.Main_frm.AccNumber.Items.Clear()
For Each Info As String In System.IO.File.ReadAllLines(AccFileR)
Accounts.Add(New Account(Info.Split(CChar(","))))
My.Forms.Main_frm.AccNumber.Items.Add(iCount)
iCount += 1
Next
My.Forms.Main_frm.AccNumber.SelectedIndex = 0
phFunctions.SelectedAccount()
What it does that it reads the file and for each line its 1 account, and each string of the account is the value after each "," at the end its just a fuction to switch between accounts with a numericUpDown, well i tried modifying it to work with the encryption but no success this what i have:
Dim iDecode As New Security()
Dim iAccs As String = Nothing
Dim iCount As Integer = CInt("0")
Accounts = New List(Of Account)
My.Forms.Main_frm.AccNumber.Items.Clear()
iAccs = iDecode.decryptString(System.IO.File.ReadAllText(AccFile))
For Each dInfo As String In iAccs
Accounts.Add(New Account(iAccs.Split(CChar(","))))
My.Forms.Main_frm.AccNumber.Items.Add(iCount)
iCount += 1
Next
My.Forms.Main_frm.AccNumber.SelectedIndex = 0
phFunctions.SelectedAccount()
And this is what i use to encrypt/decrypt:
Imports System.IO
Imports System.Security.Cryptography
Imports System.Text
Public Class Security
Protected key As String = "12345678"
Public Sub New()
'constructor
End Sub
Public Function encryptString(ByVal strtext As String) As String
Return Encrypt(strtext, key)
End Function
Public Function decryptString(ByVal strtext As String) As String
Return Decrypt(strtext, key)
End Function
'The function used to encrypt the text
Private Function Encrypt(ByVal strText As String, ByVal strEncrKey _
As String) As String
Dim byKey() As Byte = {}
Dim IV() As Byte = {&H12, &H34, &H56, &H78, &H90, &HAB, &HCD, &HEF}
Try
byKey = System.Text.Encoding.UTF8.GetBytes(Left(strEncrKey, 8))
Dim des As New DESCryptoServiceProvider()
Dim inputByteArray() As Byte = Encoding.UTF8.GetBytes(strText)
Dim ms As New MemoryStream()
Dim cs As New CryptoStream(ms, des.CreateEncryptor(byKey, IV), CryptoStreamMode.Write)
cs.Write(inputByteArray, 0, inputByteArray.Length)
cs.FlushFinalBlock()
Return Convert.ToBase64String(ms.ToArray())
Catch ex As Exception
Return ex.Message
End Try
End Function
'The function used to decrypt the text
Private Function Decrypt(ByVal strText As String, ByVal sDecrKey _
As String) As String
Dim byKey() As Byte = {}
Dim IV() As Byte = {&H12, &H34, &H56, &H78, &H90, &HAB, &HCD, &HEF}
Dim inputByteArray(strText.Length) As Byte
Try
byKey = System.Text.Encoding.UTF8.GetBytes(Left(sDecrKey, 8))
Dim des As New DESCryptoServiceProvider()
inputByteArray = Convert.FromBase64String(strText)
Dim ms As New MemoryStream()
Dim cs As New CryptoStream(ms, des.CreateDecryptor(byKey, IV), CryptoStreamMode.Write)
cs.Write(inputByteArray, 0, inputByteArray.Length)
cs.FlushFinalBlock()
Dim encoding As System.Text.Encoding = System.Text.Encoding.UTF8
Return encoding.GetString(ms.ToArray())
Catch ex As Exception
Return ex.Message
End Try
End Function
End Class
i need help editing the first code to the code the file to a string or w.e, and then read each line of that string and split it with "," to give a value to each structure of string that i have for a List (Of).