Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Windows API
  4. Des Hash

Des Hash

Scheduled Pinned Locked Moved Windows API
securitycryptographyhelpquestion
1 Posts 1 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Radiit
    wrote on last edited by
    #1

    Imports System Imports System.Text Imports System.Security Imports System.Security.Cryptography Imports Microsoft.VisualBasic Imports Microsoft.VisualBasic.Strings Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim n As Byte() = System.Text.Encoding.ASCII.GetBytes("") Dim u7 As Encoding = Encoding.UTF7 Dim desCrypto As DESCryptoServiceProvider = DESCryptoServiceProvider.Create() Dim keyBytes() As Byte = u7.GetBytes(TextBox1.Text) ReDim Preserve keyBytes(8 - 1) ReDim Preserve n(8 - 1) desCrypto.Key = keyBytes desCrypto.IV = n Dim pass() As Byte = _ System.Text.Encoding.ASCII.GetBytes(TextBox2.Text) Dim ms As New System.IO.MemoryStream Dim encStream As New CryptoStream(ms, _ desCrypto.CreateEncryptor(), _ System.Security.Cryptography.CryptoStreamMode.Write) encStream.Write(pass, 0, pass.Length) TextBox3.Text = BytesToHexString(ms.ToArray) encStream.Flush() encStream.FlushFinalBlock() End Sub Public Shared Function BytesToHexString(ByVal bytes As Byte()) As String Dim hexString As StringBuilder = New StringBuilder(64) Dim counter As Integer For counter = 0 To bytes.Length - 1 hexString.Append(String.Format("{0:X2}", bytes(counter))) Next Return hexString.ToString() End Function End Class For the above code I get the same hex string (DC22CC897735644B) when the textbox2 is 12345678 and textbox1 is 2 or 3. I get the same repeated hex strings for 4 and 5, 6 and 7 and so on. Why is it like this and can somebody help in my coding?

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups