Hej. Har aldrig været her inde før så kan ikke så godt finde rundt men håber jeg har oprette min tråd det rigtig sted.
Jeg programmere i VB .NET
Jeg fandt programmet her
http://www.codeproject.com/useritems/registration.aspDet var sejt fordi jeg ville nemlig gerne have sådan et. Så, så jeg en film på en side af det program.
Så viste de at man bare kunne lave det der regnestykke om i kode, hvis man ville have den skulle skrive en anden Key.
Nu vil jeg gerne fortælle Generatoren at den skal lave en anden slag key ved at jeg prøver og lave om i regnestykket Men så får jeg fejl i noget af kode hvor der kommer en boks op hvor der står "Specified key is not a valid size for this algorithm."
Det er det kode her den brokker sig over:
Dim input() As Byte = m_utf8.GetBytes(text)
Dim output() As Byte = Transform(input, _
m_des.CreateEncryptor(m_key, m_iv))
Nu smider jeg hele kode ind her. Kan i så hjælpe mig med at sige hvad jeg skal lave for at kunne får lov til at forkorte regnestykke fra 40 tegn til for eksempel 10 tegn.
Der er et eller andet sted i kode jeg skal lave noget om for at kunne få lov til at gøre regnestykke mindre.
Kode
Imports System.IO
Imports System.Text
Imports System.Security.Cryptography
Imports System.Net
Imports System.Drawing.Drawing2D
Public Class Enter_Code
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents Label4 As System.Windows.Forms.Label
Friend WithEvents Label5 As System.Windows.Forms.Label
Friend WithEvents TextBox2 As System.Windows.Forms.TextBox
Friend WithEvents PictureBox1 As System.Windows.Forms.PictureBox
Friend WithEvents Label7 As System.Windows.Forms.Label
Friend WithEvents Label6 As System.Windows.Forms.Label
Friend WithEvents PictureBox2 As System.Windows.Forms.PictureBox
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(Enter_Code))
Me.Label2 = New System.Windows.Forms.Label
Me.Label1 = New System.Windows.Forms.Label
Me.Label3 = New System.Windows.Forms.Label
Me.TextBox1 = New System.Windows.Forms.TextBox
Me.Label4 = New System.Windows.Forms.Label
Me.Label5 = New System.Windows.Forms.Label
Me.TextBox2 = New System.Windows.Forms.TextBox
Me.PictureBox1 = New System.Windows.Forms.PictureBox
Me.Label7 = New System.Windows.Forms.Label
Me.Label6 = New System.Windows.Forms.Label
Me.PictureBox2 = New System.Windows.Forms.PictureBox
Me.SuspendLayout()
'
'Label2
'
Me.Label2.Location = New System.Drawing.Point(16, 48)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(472, 24)
Me.Label2.TabIndex = 3
Me.Label2.Text = "This program generates a key to be used with the PAW Register program."
Me.Label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
'
'Label1
'
Me.Label1.Font = New System.Drawing.Font("Tahoma", 15.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label1.Location = New System.Drawing.Point(16, 8)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(472, 40)
Me.Label1.TabIndex = 2
Me.Label1.Text = "Registration Key Generator"
Me.Label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
'
'Label3
'
Me.Label3.Location = New System.Drawing.Point(16, 72)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(472, 48)
Me.Label3.TabIndex = 4
Me.Label3.Text = "Enter user's name below. Everything is CASE SENSITIVE! Your users will be upset w" & _
"hen thier code doesn't work if you put thier name as john doe instead of John Do" & _
"e!"
Me.Label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(64, 136)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(400, 21)
Me.TextBox1.TabIndex = 5
Me.TextBox1.Text = ""
'
'Label4
'
Me.Label4.Location = New System.Drawing.Point(16, 136)
Me.Label4.Name = "Label4"
Me.Label4.Size = New System.Drawing.Size(40, 24)
Me.Label4.TabIndex = 6
Me.Label4.Text = "Name:"
Me.Label4.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
'
'Label5
'
Me.Label5.Location = New System.Drawing.Point(16, 168)
Me.Label5.Name = "Label5"
Me.Label5.Size = New System.Drawing.Size(40, 24)
Me.Label5.TabIndex = 8
Me.Label5.Text = "Code:"
Me.Label5.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
'
'TextBox2
'
Me.TextBox2.Location = New System.Drawing.Point(64, 168)
Me.TextBox2.Name = "TextBox2"
Me.TextBox2.ReadOnly = True
Me.TextBox2.Size = New System.Drawing.Size(400, 21)
Me.TextBox2.TabIndex = 7
Me.TextBox2.Text = ""
'
'PictureBox1
'
Me.PictureBox1.Image = CType(resources.GetObject("PictureBox1.Image"), System.Drawing.Image)
Me.PictureBox1.Location = New System.Drawing.Point(456, 200)
Me.PictureBox1.Name = "PictureBox1"
Me.PictureBox1.Size = New System.Drawing.Size(32, 32)
Me.PictureBox1.TabIndex = 15
Me.PictureBox1.TabStop = False
'
'Label7
'
Me.Label7.Font = New System.Drawing.Font("Tahoma", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label7.Location = New System.Drawing.Point(336, 200)
Me.Label7.Name = "Label7"
Me.Label7.Size = New System.Drawing.Size(128, 32)
Me.Label7.TabIndex = 18
Me.Label7.Text = "Generate Code ."
Me.Label7.TextAlign = System.Drawing.ContentAlignment.MiddleRight
'
'Label6
'
Me.Label6.Font = New System.Drawing.Font("Tahoma", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label6.Location = New System.Drawing.Point(48, 200)
Me.Label6.Name = "Label6"
Me.Label6.Size = New System.Drawing.Size(120, 32)
Me.Label6.TabIndex = 17
Me.Label6.Text = "Cancel"
Me.Label6.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
'
'PictureBox2
'
Me.PictureBox2.Image = CType(resources.GetObject("PictureBox2.Image"), System.Drawing.Image)
Me.PictureBox2.Location = New System.Drawing.Point(16, 200)
Me.PictureBox2.Name = "PictureBox2"
Me.PictureBox2.Size = New System.Drawing.Size(32, 32)
Me.PictureBox2.TabIndex = 16
Me.PictureBox2.TabStop = False
'
'Enter_Code
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 14)
Me.ClientSize = New System.Drawing.Size(498, 240)
Me.Controls.Add(Me.PictureBox1)
Me.Controls.Add(Me.Label7)
Me.Controls.Add(Me.Label6)
Me.Controls.Add(Me.PictureBox2)
Me.Controls.Add(Me.Label5)
Me.Controls.Add(Me.TextBox2)
Me.Controls.Add(Me.Label4)
Me.Controls.Add(Me.TextBox1)
Me.Controls.Add(Me.Label3)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.Label1)
Me.Font = New System.Drawing.Font("Tahoma", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle
Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
Me.MaximizeBox = False
Me.MinimizeBox = False
Me.Name = "Enter_Code"
Me.Text = "Enter Registration Code"
Me.ResumeLayout(False)
End Sub
#End Region
Public NameNum As String
Public Sub CheckAdmin()
Checkmatch()
End Sub
Public Sub Checkmatch()
NameNum = TextBox1.Text
NameNum = des.Encrypt(NameNum)
NameNum = NameNum.Remove(0, (NameNum.Length - 10))
TextBox2.Text = NameNum
If MsgBox("The user's code has been generated and is: " + NameNum + (Chr(13)) + (Chr(13)) + " Would you like to copy this text to the clipboard?", MsgBoxStyle.YesNo, "Success!") = MsgBoxResult.Yes Then
TextBox2.Select(0, TextBox2.Text.Length)
TextBox2.Copy()
Else
End If
End Sub
Public Sub ProcessOK()
End Sub
#Region "DES"
Private ReadOnly key() As Byte = _
{5, 4, 45, 4, 45, 51, 7, 8, 9, 56, 11, 182, 2, 12, _
15, 16, 57, 18, 45, 20, 21, 22, 23, 3}
Private ReadOnly iv() As Byte = {8, 3, 6, 5, 54, 2, 1, 32}
' instantiate the class with the arrays
Private des As New cTripleDES(key, iv)
Friend Class cTripleDES
' define the triple des provider
Private m_des As New TripleDESCryptoServiceProvider
' define the string handler
Private m_utf8 As New UTF8Encoding
' define the local property arrays
Private m_key() As Byte
Private m_iv() As Byte
Public Sub New(ByVal key() As Byte, ByVal iv() As Byte)
Me.m_key = key
Me.m_iv = iv
End Sub
Public Function Encrypt(ByVal input() As Byte) As Byte()
Return Transform(input, m_des.CreateEncryptor(m_key, m_iv))
End Function
Public Function Decrypt(ByVal input() As Byte) As Byte()
Return Transform(input, m_des.CreateDecryptor(m_key, m_iv))
End Function
Public Function Encrypt(ByVal text As String) As String
Dim input() As Byte = m_utf8.GetBytes(text)
Dim output() As Byte = Transform(input, _
m_des.CreateEncryptor(m_key, m_iv))
Return Convert.ToBase64String(output)
End Function
Public Function Decrypt(ByVal text As String) As String
Dim input() As Byte = Convert.FromBase64String(text)
Dim output() As Byte = Transform(input, _
m_des.CreateDecryptor(m_key, m_iv))
Return m_utf8.GetString(output)
End Function
Private Function Transform(ByVal input() As Byte, _
ByVal CryptoTransform As ICryptoTransform) As Byte()
' create the necessary streams
Dim memStream As MemoryStream = New MemoryStream
Dim cryptStream As CryptoStream = New _
CryptoStream(memStream, CryptoTransform, _
CryptoStreamMode.Write)
' transform the bytes as requested
cryptStream.Write(input, 0, input.Length)
cryptStream.FlushFinalBlock()
' Read the memory stream and convert it back into byte array
memStream.Position = 0
Dim result(CType(memStream.Length - 1, System.Int32)) As Byte
memStream.Read(result, 0, CType(result.Length, System.Int32))
' close and release the streams
memStream.Close()
cryptStream.Close()
' hand back the encrypted buffer
Return result
End Function
End Class
#End Region
Private Sub Enter_Code_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
CheckAdmin()
End Sub
Private Sub Label7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label7.Click
CheckAdmin()
End Sub
Private Sub PictureBox2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox2.Click
Application.Exit()
End Sub
Private Sub Label6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label6.Click
Application.Exit()
End Sub
End Class
håber der er nogen der kan hjælpe.