Despues de casi 6 meses que habia dejado de escribir en mi blog, ahora vuelvo con un articulo que me parecio bastante interesante…
Lo que hace este pequeño codigo es encriptar el querystring de una URL,bueno espero que les sea util este articulo.
Imports System Imports System.IO Imports System.Xml Imports System.Text Imports System.Security.Cryptography Public Class Encryption64 Private key() As Byte = {} Private IV() As Byte = {&H12, &H34, &H56, &H78, &H90, &HAB, &HCD, &HEF} Public Function Decrypt(ByVal stringToDecrypt As String, _ ByVal sEncryptionKey As String) As String Dim inputByteArray(stringToDecrypt.Length) As Byte Try key = System.Text.Encoding.UTF8.GetBytes(Left(sEncryptionKey, 8)) Dim des As New DESCryptoServiceProvider() inputByteArray = Convert.FromBase64String(stringToDecrypt) Dim ms As New MemoryStream() Dim cs As New CryptoStream(ms, des.CreateDecryptor(key, 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 e As Exception Return e.Message End Try End Function Public Function Encrypt(ByVal stringToEncrypt As String, _ ByVal SEncryptionKey As String) As String Try key = System.Text.Encoding.UTF8.GetBytes(Left(SEncryptionKey, 8)) Dim des As New DESCryptoServiceProvider() Dim inputByteArray() As Byte = Encoding.UTF8.GetBytes( _ stringToEncrypt) Dim ms As New MemoryStream() Dim cs As New CryptoStream(ms, des.CreateEncryptor(key, IV), _ CryptoStreamMode.Write) cs.Write(inputByteArray, 0, inputByteArray.Length) cs.FlushFinalBlock() Return Convert.ToBase64String(ms.ToArray()) Catch e As Exception Return e.Message End Try End Function End Class
interesante post sobre seguridad. si tienes más temitas sueltos sobre encriptación y seguridad en logueos también te agradecería si publicas algunos articulos sobre eso. bytes
Sabes que con algunos valores da error y no se por que ? me dice que
[System.FormatException] = {«Longitud no válida para una matriz de caracteres Base-64.»}
los valores que encripto son 2 , 5 , 8 no eh probado mas pero con esos se cae
Hola funciona bien solo la cadena key tiene q ser de mas d 8 caracteres (sEncryptionKey)… por ej «123456789»
Pero me queda la duda si al encryptar no manda un «&» en la cadena ya q esto tronaria el querystring.. lo han considerado?
Muchas gracias por el script…
Muy buen post, muchas gracias por la rutina, estuve investigando algunas maneras para encriptar el querystring, inclusive descargue algunas dlls, pero en su mayoria eran muy inestables, necesitabas muchas validaciones y mucho recurso en el server… esta clase es muy sencilla de implementar y usar … de nuevo gracias…
Saludos
Oigan que buena rutina la verdad, gracias por la ayuda a quien publico esto
Excelente post acerca de la seguridad !
me parece muy bien el post pero yo soy nuevo en esto y quisiera que me explicaran mas sobre como implementarlo.. gracias
no se nada
I feel this is one of the most significant information for me.
And i am happy reading your article. But want to commentary on some basic things, The site style is perfect,
the articles is truly excellent : D. Good task, cheers
naturally like your web-site but you have to test the spelling on quite a few of your posts.
A number of them are rife with spelling problems and I in finding it very bothersome
to tell the reality on the other hand I will definitely come again again.
buen artículo, pero por favor un ejemplo de invocar a url y cómo recuperar sus valores desde la otra página. Gracias