· Convierte entero a caracter
#Region " Byte To Char "
' [ Byte To Char Function ]
'
' // By Elektro H@cker
'
' Examples :
' MsgBox(Byte_To_Char(97)) ' Result: a
Private Function Byte_To_Char(ByVal int As Int32) As String
Return Convert.ToChar(int)
End Function
#End Region
· Convierte caracter a entero
#Region " Char To Byte "
' [ Char To Byte Function ]
'
' // By Elektro H@cker
'
' Examples :
' MsgBox(Char_To_Byte("a")) ' Result: 97
' Dim MyChar As String = "a" : MsgBox(Chr(Char_To_Byte(MyChar))) ' Result: a ( ...xD )
Private Function Char_To_Byte(ByVal str As String) As Int32
Dim character As Char = str & "c"
Return Convert.ToByte(character)
End Function
#End Region
· Obtiene el SHA1 de un string
#Region " Get SHA1 Of String "
' [ Get SHA1 Of String Function ]
'
' Examples :
' MsgBox(Get_SHA1_Of_String("Hello")) ' Result: D2EFCBBA102ED3339947E85F4141EB08926E40E9
Private Function Get_SHA1_Of_String(ByVal str As String) As String
'create our SHA1 provider
Dim sha As System.Security.Cryptography.SHA1 = New System.Security.Cryptography.SHA1CryptoServiceProvider()
Dim hashedValue As String = String.Empty
'hash the data
Dim hashedData As Byte() = sha.ComputeHash(System.Text.Encoding.Unicode.GetBytes(str))
'loop through each byte in the byte array
For Each b As Byte In hashedData
'convert each byte and append
hashedValue += String.Format("{0,2:X2}", b)
Next
'return the hashed value
Return hashedValue
End Function
#End Region
· Obtiene el SHA1 de un archivo
#Region " Get SHA1 Of File "
' [ Get SHA1 Of File Function ]
'
' Examples :
' MsgBox(Get_SHA1_Of_File("C:\File.txt"))
Private Function Get_SHA1_Of_File
(ByVal File As String) As String Dim File_Stream
As New System.
IO.
FileStream(File, IO.
FileMode.
Open) Dim sha As New System.Security.Cryptography.SHA1CryptoServiceProvider
Dim hash As Array
Dim shaHash As String
Dim sb As New System.Text.StringBuilder
sha.ComputeHash(File_Stream)
hash = sha.Hash
For Each hashByte As Byte In hash : sb.Append(String.Format("{0:X1}", hashByte)) : Next
shaHash = sb.ToString
File_Stream.Close()
Return shaHash
End Function
#End Region
· cifra un string en AES
#Region " AES Encrypt "
' [ AES Encrypt Function ]
'
' Examples :
' MsgBox(AES_Encrypt("Test_Text", "Test_Password")) ' Result: cv/vYwpl51/dxbxSMNSPSg==
Public Function AES_Encrypt(ByVal input As String, ByVal pass As String) As String
Dim AES As New System.Security.Cryptography.RijndaelManaged
Dim Hash_AES As New System.Security.Cryptography.MD5CryptoServiceProvider
Dim encrypted As String = ""
Try
Dim hash(31) As Byte
Dim temp As Byte() = Hash_AES.ComputeHash(System.Text.ASCIIEncoding.ASCII.GetBytes(pass))
Array.Copy(temp, 0, hash, 0, 16)
Array.Copy(temp, 0, hash, 15, 16)
AES.Key = hash
AES.Mode = Security.Cryptography.CipherMode.ECB
Dim DESEncrypter As System.Security.Cryptography.ICryptoTransform = AES.CreateEncryptor
Dim Buffer As Byte() = System.Text.ASCIIEncoding.ASCII.GetBytes(input)
encrypted = Convert.ToBase64String(DESEncrypter.TransformFinalBlock(Buffer, 0, Buffer.Length))
Return encrypted
Catch ex As Exception
Return Nothing
End Try
End Function
#End Region
· descifra un string AES
#Region " AES Decrypt "
' [ AES Decrypt Function ]
'
' Examples :
' MsgBox(AES_Decrypt("cv/vYwpl51/dxbxSMNSPSg==", "Test_Password")) ' Result: Test_Text
Public Function AES_Decrypt(ByVal input As String, ByVal pass As String) As String
Dim AES As New System.Security.Cryptography.RijndaelManaged
Dim Hash_AES As New System.Security.Cryptography.MD5CryptoServiceProvider
Dim decrypted As String = ""
Try
Dim hash(31) As Byte
Dim temp As Byte() = Hash_AES.ComputeHash(System.Text.ASCIIEncoding.ASCII.GetBytes(pass))
Array.Copy(temp, 0, hash, 0, 16)
Array.Copy(temp, 0, hash, 15, 16)
AES.Key = hash
AES.Mode = Security.Cryptography.CipherMode.ECB
Dim DESDecrypter As System.Security.Cryptography.ICryptoTransform = AES.CreateDecryptor
Dim Buffer As Byte() = Convert.FromBase64String(input)
decrypted = System.Text.ASCIIEncoding.ASCII.GetString(DESDecrypter.TransformFinalBlock(Buffer, 0, Buffer.Length))
Return decrypted
Catch ex As Exception
Return Nothing
End Try
End Function
#End Region
· Devuelve el código fuente de una URL
#Region " Get URL SourceCode "
' [ Get URL SourceCode Function ]
'
' Examples :
' MsgBox(Get_URL_SourceCode("http://www.el-hacker.com"))
Function Get_URL_SourceCode(ByVal url As String) As String
Dim sourcecode As String = String.Empty
Try
Dim request As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create(url)
Dim response As System.Net.HttpWebResponse = request.GetResponse()
Dim sr As System.IO.StreamReader = New System.IO.StreamReader(response.GetResponseStream())
sourcecode = sr.ReadToEnd()
Catch ex As Exception
MsgBox(ex.Message)
End Try
Return sourcecode
End Function
#End Region
· Intercambia entre el modo pantalla completa o modo normal.
#Region " Toogle FullScreen "
' [ Toogle FullScreen ]
'
' // By Elektro H@cker
'
' Examples :
' Toogle_FullScreen()
Dim MyFormBorderStyle = Me.FormBorderStyle
Dim MyWindowState = Me.WindowState
Dim MyTopMost = Me.TopMost
Dim IsFullscreened As Boolean
Public Sub Toogle_FullScreen()
If Not IsFullscreened Then
IsFullscreened = True
Me.FormBorderStyle = FormBorderStyle.None
Me.WindowState = FormWindowState.Maximized
Me.TopMost = True
ElseIf IsFullscreened Then
IsFullscreened = False
Me.FormBorderStyle = MyFormBorderStyle
Me.WindowState = MyWindowState
Me.TopMost = MyTopMost
End If
End Sub
#End Region
· Devuelve la versión del Framework con el que se ha desarrollado una applicación (o DLL).
#Region " Get FrameWork Of File "
' [ Get FrameWork Of File Function ]
'
' Examples :
' MsgBox(Get_FrameWork_Of_File("C:\My .Net Application.exe"))
Private Function Get_FrameWork_Of_File
(ByVal File As String) As String Try
Dim FW
As System.
Reflection.
Assembly = Reflection.
Assembly.
ReflectionOnlyLoadFrom(File) Return FW.ImageRuntimeVersion
Catch ex As Exception
Return Nothing ' Is not managed code
End Try
End Function
#End Region
· Devuelve positivo si el número es primo
#Region " Number Is Prime? "
' [ Number Is Prime? Function ]
'
' Examples :
' MsgBox(Number_Is_Prime(4)) ' Result: False
Private Function Number_Is_Prime(ByVal Number As Long, Optional ByVal f As Integer = 2) As Boolean
If Number = f Then Return True
If Number Mod f = 0 Or Number = 1 Then Return False _
Else Return Number_Is_Prime(Number, f + 1)
End Function
#End Region
· Valida si un string se puede usar como nombre de archivo en Windows
#Region " Validate Windows FileName "
' [ Validate Windows FileName Function ]
'
' Examples :
' MsgBox(Validate_Windows_FileName("C:\Test.txt")) ' Result: True
' MsgBox(Validate_Windows_FileName("C:\Te&st.txt")) ' Result: False
Private Function Validate_Windows_FileName(ByRef FileName As String) As Boolean
Dim Windows_Reserved_Chars As String = "\/:*?""<>|"
For i As Integer = 0 To FileName.Length - 1
If Windows_Reserved_Chars.Contains(FileName(i)) Then
Return False ' FileName is not valid
End If
Next
Return True ' FileName is valid
End Function
#End Region
· cifra un string a Base64
#Region " String To Base64 "
' [ String To Base64 Function ]
'
' // By Elektro H@cker
'
' Examples :
' MsgBox(String_To_Base64("Test")) ' Result: VGVzdA==
Private Function String_To_Base64(ByVal str As String) As String
Return Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(str))
End Function
#End Region
· descifra un string Base64 a string
#Region " Base64 To String "
' [ Base64 To String Function ]
'
' // By Elektro H@cker
'
' Examples :
' MsgBox(Base64_To_String("VGVzdA==")) ' Result: Test
Private Function Base64_To_String(ByVal str As String) As String
Return System.Text.Encoding.ASCII.GetString(Convert.FromBase64String(str))
End Function
#End Region