Hello ElitePvpers
What's Samson Engine?
With Samson Engine You Can Easily Store Many Informations Like Strings Or
Files Into One File,While Everything Is Encrypted With A Key That You Define!
What's The Profits...?
Now You Dont Have To Use External Images Or Informations That Can Be Easily Edited. You Just Get Everything You Need From One Protected File.
How To Use?
A) Creating A Resource File
First Add The Samson Engine Library To Your Project
Then At The Beging Of The Code Add This:
Code:
Imports SamsonEngine
After That Create A Writer, For Example
Code:
Dim Writer As New Samson_Writer("Location", "Encryption Key")
To Add String Resources Just Use This Function:
Code:
Writer.Add("Resource_ID","Resource_Value")
To Add File Values Do This:
Code:
Dim Image_Bytes As Byte() = My.Computer.FileSystem.ReadAllBytes("C:\Image.jpg")
Writer.Add("Image", Convert.ToBase64String(Image_Bytes))
To Create The Resource File Just Use This Function:
Code:
If Writer.Generate = True Then
MsgBox("Done")
Else
MsgBox(Writer.Get_Last_Error)
End If
That's It!! You Have Succesfully Created A Resource File
Now To Read The Resources:
B) Reading A Resource File
First Add The Samson Engine Library To Your Project
Then At The Beging Of The Code Add This:
Code:
Imports SamsonEngine
After That Create A Reader, For Example
Code:
Dim Reader As New Samson_Reader("Location", "Encryption Key")
To Read A Value Just Use This Function:
Code:
Reader.Get_Value("Resource_Id")
For Example:
Code:
MsgBox(Reader.Get_Value("Server_Ip"))
Also You Can Use This Function For Image Resources:
Code:
Reader.Get_Image("Image_Id")
For_Example:
Code:
Me.BackgroundImage = Reader.Get_Image("BG_Image")
I Hope You Find My Library Usefull!
Also The Source Code:

I Am Not A Perfect Programer I Am Sorry!
PHP Code:
Imports System
Imports System.Security.Cryptography
Imports System.IO
Imports System.Text
Imports System.Windows.Forms
Public Class Samson_Writer
Private resource_list As New System.Windows.Forms.ListView
Private resource_location As String
Private enc_key As String
Private salt_key = "<3Tesla1995-BlazeIT"
Private error_message As String
Sub New(ByVal location As String, ByVal encryption_key As String)
resource_location = location
enc_key = encryption_key
End Sub
Public Sub Add(ByVal id As String, ByVal value As String)
Dim resource As New ListViewItem
resource.Text = id
resource.SubItems.Add(value)
resource_list.Items.Add(resource)
End Sub
Public Function Generate() As Boolean
Try
Dim Samson_File As String
Samson_File = "<Samson File>" + vbNewLine
Samson_File = Samson_File + "~Samson Resource File Generated By Samson Engine~" + vbNewLine
Samson_File = Samson_File + "<Resources>" + vbNewLine + vbNewLine
For Each item As ListViewItem In resource_list.Items
Samson_File = Samson_File + "[R]" + AESEncrypt(item.Text + "|" + item.SubItems.Item(1).Text, enc_key, salt_key) + vbNewLine
Next
Samson_File = Samson_File + vbNewLine + "</Resources>" + vbNewLine
Samson_File = Samson_File + "</Samson File>"
My.Computer.FileSystem.WriteAllText(resource_location, Samson_File, False)
Return True
resource_list.Clear()
Catch ex As Exception
error_message = ex.Message
Return False
End Try
End Function
Public Sub Clear_Resources()
resource_list.Items.Clear()
End Sub
Public Sub Remove_Resource(ByVal index As Integer)
resource_list.Items.RemoveAt(index)
End Sub
Public Function Get_Last_Error()
Return error_message
End Function
Private Function AESEncrypt(ByVal PlainText As String, ByVal Password As String, ByVal salt As String)
Dim HashAlgorithm As String = "SHA1"
Dim PasswordIterations As String = 2
Dim InitialVector As String = "CanEncryption123"
Dim KeySize As Integer = 256
If (String.IsNullOrEmpty(PlainText)) Then
Return ""
Exit Function
End If
Dim InitialVectorBytes As Byte() = Encoding.ASCII.GetBytes(InitialVector)
Dim SaltValueBytes As Byte() = Encoding.ASCII.GetBytes(salt)
Dim PlainTextBytes As Byte() = Encoding.UTF8.GetBytes(PlainText)
Dim DerivedPassword As PasswordDeriveBytes = New PasswordDeriveBytes(Password, SaltValueBytes, HashAlgorithm, PasswordIterations)
Dim KeyBytes As Byte() = DerivedPassword.GetBytes(KeySize / 8)
Dim SymmetricKey As RijndaelManaged = New RijndaelManaged()
SymmetricKey.Mode = CipherMode.CBC
Dim CipherTextBytes As Byte() = Nothing
Using Encryptor As ICryptoTransform = SymmetricKey.CreateEncryptor(KeyBytes, InitialVectorBytes)
Using MemStream As New MemoryStream()
Using CryptoStream As New CryptoStream(MemStream, Encryptor, CryptoStreamMode.Write)
CryptoStream.Write(PlainTextBytes, 0, PlainTextBytes.Length)
CryptoStream.FlushFinalBlock()
CipherTextBytes = MemStream.ToArray()
MemStream.Close()
CryptoStream.Close()
End Using
End Using
End Using
SymmetricKey.Clear()
Return Convert.ToBase64String(CipherTextBytes)
End Function
End Class
Public Class Samson_Reader
Private salt_key = "<3Tesla1995-BlazeIT"
Private resource_location As String
Private key As String
Sub New(ByVal Location As String, ByVal Encryption_Key As String)
resource_location = Location
key = Encryption_Key
End Sub
Public Function Get_Value(ByVal id As String) As String
Dim fileReader As System.IO.StreamReader
Dim lineRead As String
Dim non_line As String
Dim raw_string As String
Dim name As String
Dim value As String
fileReader = File.OpenText(resource_location)
While fileReader.Peek <> -1
lineRead = fileReader.ReadLine()
If lineRead.StartsWith("[R]") = True Then
non_line = lineRead.Replace("[R]", "")
raw_string = AESDecrypt(non_line, key, salt_key)
name = raw_string.Substring(0, raw_string.LastIndexOf("|"))
value = raw_string.Substring(raw_string.LastIndexOf("|") + 1)
If name = id Then
Return value
Exit While
End If
End If
End While
End Function
Function Get_Image(ByVal id As String) As System.Drawing.Image
Dim fileReader As System.IO.StreamReader
Dim lineRead As String
Dim non_line As String
Dim raw_string As String
Dim name As String
Dim value As String
Dim stream As New MemoryStream
fileReader = File.OpenText(resource_location)
While fileReader.Peek <> -1
lineRead = fileReader.ReadLine()
If lineRead.StartsWith("[R]") = True Then
non_line = lineRead.Replace("[R]", "")
raw_string = AESDecrypt(non_line, key, salt_key)
name = raw_string.Substring(0, raw_string.LastIndexOf("|"))
value = raw_string.Substring(raw_string.LastIndexOf("|") + 1)
If name = id Then
Dim image_bytes As Byte() = Convert.FromBase64String(value)
stream.Write(image_bytes, 0, image_bytes.Length)
Return System.Drawing.Image.FromStream(stream)
Exit While
End If
End If
End While
End Function
Private Function AESDecrypt(ByVal CipherText As String, ByVal password As String, ByVal salt As String) As String
Dim HashAlgorithm As String = "SHA1"
Dim PasswordIterations As String = 2
Dim InitialVector As String = "CanEncryption123"
Dim KeySize As Integer = 256
If (String.IsNullOrEmpty(CipherText)) Then
Return ""
End If
Dim InitialVectorBytes As Byte() = Encoding.ASCII.GetBytes(InitialVector)
Dim SaltValueBytes As Byte() = Encoding.ASCII.GetBytes(salt)
Dim CipherTextBytes As Byte() = Convert.FromBase64String(CipherText)
Dim DerivedPassword As PasswordDeriveBytes = New PasswordDeriveBytes(password, SaltValueBytes, HashAlgorithm, PasswordIterations)
Dim KeyBytes As Byte() = DerivedPassword.GetBytes(KeySize / 8)
Dim SymmetricKey As RijndaelManaged = New RijndaelManaged()
SymmetricKey.Mode = CipherMode.CBC
Dim PlainTextBytes As Byte() = New Byte(CipherTextBytes.Length - 1) {}
Dim ByteCount As Integer = 0
Using Decryptor As ICryptoTransform = SymmetricKey.CreateDecryptor(KeyBytes, InitialVectorBytes)
Using MemStream As MemoryStream = New MemoryStream(CipherTextBytes)
Using CryptoStream As CryptoStream = New CryptoStream(MemStream, Decryptor, CryptoStreamMode.Read)
ByteCount = CryptoStream.Read(PlainTextBytes, 0, PlainTextBytes.Length)
MemStream.Close()
CryptoStream.Close()
End Using
End Using
End Using
SymmetricKey.Clear()
Return Encoding.UTF8.GetString(PlainTextBytes, 0, ByteCount)
End Function
End Class
Find My Original Post Here: