Knække Kryptering
Hejsa, jeg står med et lille problem, en kammerrat som jeg har er vildt god til at programmere, han har kyrpteret en tekst jeg skal knække ved ikke hvordan, teksten er: Ü<Å8½*yû°^è¶ß±Ç¶kL;?Ó.¦¶?¾?ûK"Êmê(çô"wOg programmets import system er: Imports System.IO
Imports System.Security.Cryptography
Class FileEncrypt
Public Shared Function ConvertStringToByteArray(ByVal s As [String]) As [Byte]()
Dim ca As [Char]() = s.ToCharArray()
Dim ba(ca.Length - 1) As [Byte]
Dim i As Integer
For i = 0 To ba.Length - 1
ba(i) = Convert.ToByte(ca(i))
Next i
Return ba
End Function 'ConvertStringToByteArray
Public Shared Sub Main()
Dim fs2 As New System.IO.MemoryStream()
Console.WriteLine("Enter Some Text to be stored in encrypted file:
Dim strinput As [String] = Console.ReadLine()
Dim bytearrayinput As [Byte]() = ConvertStringToByteArray(strinput)
Dim des As New DESCryptoServiceProvider()
Dim desencrypt As ICryptoTransform = des.CreateEncryptor()
Dim cryptostream As New CryptoStream(fs2, desencrypt, CryptoStreamMode.Write)
cryptostream.Write(bytearrayinput, 0, bytearrayinput.Length)
cryptostream.FlushFinalBlock()
Dim fs3 As New System.IO.MemoryStream()
Dim bytes As [Byte]()
fs2.Position = 0
ReDim bytes(fs2.Length)
fs2.Read(bytes, 0, fs2.Length)
cryptostream.Close()
Dim I, cnt As Integer
Dim str As String
For I = 0 To bytes.Length - 1
If Not (bytes(I) = 0) Then
cnt += cnt
str += Chr(bytes(I))
Else
Exit For
End If
Next I
Console.WriteLine(str)
fs3.Write(bytes, 0, I)
fs3.Position = 0
Dim desdecrypt As ICryptoTransform = des.CreateDecryptor()
Dim cryptostreamDecr As New CryptoStream(fs3, desdecrypt, CryptoStreamMode.Read)
Console.WriteLine(New StreamReader(cryptostreamDecr).ReadToEnd)
str = ""
For I = 0 To des.Key.Length - 1
If Not (bytes(I) = 0) Then
str += Chr(des.Key(I))
Else
Exit For
End If
Next I
Console.WriteLine(str)
Console.WriteLine("Press Enter to continue...")
Console.ReadLine()
Hvad gør jeg ??? hjælp !