Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




How To Create A Hash


I'd like to create the same hashes that windows does, i know it uses LM HASH and NT HASH.
I'd like to know if there is any function or api to create the same hash that windows does.

for exemple, this hash: 36c3363007203fd4aad3b435b51404ee
was created for the password: 12ast89
i tested it in my computer.

I'v found this info but i can't understand it: http://de.samba.org/samba/ftp/docs/h...NCRYPTION.html




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
MD5 Hash
hi, is the some kind of MD5 hash function in VB tat does the same as the one in PHP or is there an easy way to work it out?

i just want to hash a simple text string (i think). its for an encryption function i have in PHP and im trying to re-write it in VB. so far i think i just need it to work with plain text

LM Hash In Vb
Hi, how can I get a LM (Lan Manager) hash from a string in VB?
I've been looking all over but I can't find it anywhere.

MD4 Hash...
I have looked on Google and have gotten tons of things concerning MD4 hashes. Currently, I am using an OCX control to calculate the hashes. However, I want actually VB code to use instead of an OCX. Do any of you know where I can find something to help me with this? I have looked through some source code, but none of it makes sense to me. (I have currently researched Rehash, Crypto API, and other source codes. The OCX I am using is EDCrypt.)

Hash Help
Thanks to BillSoo for this code...
Code:
Private Function HashPassword(ByVal pw As String) As Long
Dim varChar As Long, varTemp As Long

For varChar = 1 To Len(pw)
varTemp = Asc(Mid$(pw, varChar, 1)) Xor varTemp
Next varChar
Call Rnd(-1)
Randomize varTemp
HashPassword = (Rnd() * &H7FFFFFFF) And &HFFFFFFFF
End Function
My question is, is there any way to "un-hash" so you could see the string that you originally started with before you hashed? Thanks!

Hash
is there such thing as a hash in visual basic..

a hash is a way to make a dictionary..... for example:

if u wanted to make a program for upper and lower case letters like this

if u tpe a it spits out @

or s it spis out $

etc..

Hash
Is there a "hash" datatype in vb(like in perl '%') I have been faking it using a collection but that means I need two arrays one holds the value and one to hold names(indexes) for the collection...It is just a lot of code for something that can be done in perl likd %hash = (name => "henry", etc...);

MD5 Hash
Does anyone have a copy of the MD5 source code in VB/Basic i would realy like to learn how it works, not just implement it. So please no api's without source. btw, i already have the source in JS, but it confuses me.

What Is The Hash For!!!!
hi, my question is simple what is the difference between these two statements:

sum = 0
and
sun = 0#

what is the hash used for?

MD5 Hash
Hey guys,

Is there a VB6 function to create a MD5 hash from a string?

Hash/Encoding In VBA
I would like to use use a one-way hash for storing user passwords in a input file. I would much prefer to use a built-in windows hash (such as System.Security.Cryptography.MD5). This would prevent anyone from opening my code and reading the encription password.

1) Does anyone know if the MD5 hash is available in VBA? (I can reference the System.dll but cant get any further than that.)
2) Are there any other built-in hashes for VBA?

Thanks, Jeff

Hash String SHA-1
i want to hash a password with MD5 and then compare it to a password at a remote database.

i need to know how to hash it first with minimal code (if possible)
ive tried googling but cant find anything for vb6 or it didnt work

p.s. accidently mention SHA-1 in topic..i mean MD5

# Hash If/Then/Else Statements
I've noticed that in declarations you see If/Then/Else statements there prefixxed with #. I assume the # is there because there not inside a sub.

But what can these be used for?, how do you use?

Also, you they say provide the ability. If you try declaring an API when the .dll required for it doesn't exist. It could not declare it instead of crash?

Hash String?
Basically I want to be able to create a string of characters that when unencoded, my program can extract variables/information from.

Example,

Say I have the following variables:
Username
Time
Filename
URL
Content Type

---------------------------------
Those are all random so dont get caught up in the names of the variables.
---------------------------------

Then encode all those into a string of characters say..
H4HOI3N4O5NOK2MN3O4KNM2O35NJO4N56L4N56L2N354OKN1345LN14L5N1

Then after entering tht string in to my program be able to unencode it and get the information out.

**EDIT
Btw, I dont mind doing the work. If someone can push me into the right direction. Like the proper name for what I am trying to accomplish.

Thanks!

Md5 File Hash
Up to this day i've been using aamd532.dll to calculcate hashes. All the code you needed was:


Code:
Private Declare Sub MDFile Lib "aamd532.dll" (ByVal f As String, ByVal r As String)

Public Function MD5File(File As String) As String
Dim r As String * 32
r = Space(32)
MDFile File, r
MD5File = r
End Function

And it returned the hash. Now i think its time for me to go on my own and make a function to return the hash of a file.

Why Im asking this
Im asking how to do this because my program is getting filled with other files ( 3d party ) and want to get at least a few off my back.

Can someone point me in the right direction as what api's to use. I heard CryptoApi did this but it was complicated?

Hash Algo
Ok, I want to create an associative array (that'd be a hash table in Perl). Basically that's a two-dimensional array with values in first dimension being hashes of some strings and the second dimension containing the corresponding values (pointers actually, but implementation is of little essence here).

Anyways I need some nice not overly collisive hash function....something like crc16/32, md5,...searching for such I've found some half-meg ocx's and dlls - not very nice for a 100byte long function, is it? So I'm kind'a interested if it's possible to code one in pure VB?

Hash Encryption
First of I just want to say that if you haven't read Bill's tutorial on Encryption you are missing out.

I have decided to hash my passwords for my program, but I have a couple questions about Bill's example...
Code:
Private Function HashPassword(ByVal pw As String) As Long
Dim i As Long, t As Long

For i = 1 To Len(pw)
t = Asc(Mid$(pw, i, 1)) Xor t
Next i
Call Rnd(-1)
Randomize t
HashPassword = (Rnd() * &H7FFFFFFF) And &HFFFFFFFF
End Function

What is Asc?

What is Rnd? a separate function?

What is &H7FFFFFFF?

Thanks for the help!

Hash Algorithm
Just a quick question really,
Anyone know where I can find a hash algorithm which I can use in VB? I'm using an external DLL (not the most secure way, I know) for encryption and decryption, but I'd like to add a hash mechanism.

Any help is appreciated

File Hash
I've seen people do it before... Well, is there an easy way to get the Hash of a file?

an example of what i want to do is at: http://virusscan.jotti.org/
After you scan a file it gives you a hash, and that is exactly what i want to do

If anybody could help me that would be great.

Thanks

Hash Tables
Hello

I have a collection of 5808 pieces of data. The are arranged like this:

0.73054,51.30238

Using just a normal search whereby its listed and check 1 by 1, takes far to long. I was wondering how to speed this up, searching on the forum ive heard of hash tables, and how they are used with words. Would it be possible to use them here? and how much time would it save?

File Hash
I've managed to make string hashes (MD5 and SHA-1), but I can't find out how to make a hash out of a file. I have tried using the first 1024b of the content and some different values (LOF, etc..). The strange thing is that if I do this in PHP (md5(content)), it returns the right stuff..

PHP Example:

PHP Code:



function md5_hash($file) {
        $fd = fopen($file, 'r');
        $contents = fread($fd, filesize($file));
        fclose($fd);
        return md5($contents);





Though it doesn't work the same way in VB..
I'm a bit confused

Hash Tables?
I'm interested in this string hashing. Does anyone have any samples?

Edit: Reference to thread http://www.xtremevbtalk.com/showthread.php?t=97820

Make Md5 Hash
I'm trying to make a md5 hash in vb, for example, I'm making a security scheme and want to make a md5 hash of say a hard drive serial within vb.

But in all honestly, I've tried looking for md5 functions but cannot find one I'm after that accurately hashes a string

Note: I found one that hashes a file but not a single string like the function md5() in php would do because I would be comparing these.

Can anyone point me in the right direction to a working function.

Salted Hash
Does VB6 have any inbuilt functionality to generate a salted hash? I want to use this to generate a password. So I will be supplied a password and the code will return a salted hash which I will be storing in the registry. Any ideas?

Usage Of Hash
Can any one tell me the usage of Hash.
What is the difference betn

If str = "" Then
MsgBox "sterksdrk"
End If

and

#If str = "" Then
MsgBox "sterksdrk"
#End If


I find no compilation error while running but the difference
is at runtimre.

regards
Viswanathan

Vector Or Hash In VB6
Is there a data type similar to the Java Vector or the Perl hash in VB6?

Hash Algorithm
I wouldl like to incorporate the hash algorithm into my program to encrytion some data and send. Any of you have any idea where to get the lib or dll and how to make it work?

Thanks in advance

Hash Functions
vb guru's how can i hash 20 names into 30 locations, and count number of collisions using entire name as key.

Hash Tables ....
i have a project , about hash tables ,
i have to reference all courses in my university with credits etc .. and i am supposed to use Hash Tables ...
the thing is i did not attend the lecture where the professor explained it ...
and the book is horrible .. anyone has any idea where i can get some documentation ?
(on the net) or if vb contains a hash "class" ??

------------------
- regards -
- razzaj -

Hash And Salt
I have been playing around with a password hash and salt scheme for my application

But i keep getting an error message when it executes the command object

i get the error

Unable to cast object of type 'System.byte[]' to type 'system.inconvertible'

Any suggestions?
[code]
Sub CreateAccount(ByVal sender As Object, ByVal e As EventArgs)
Dim literror As New LiteralControl
'1. Create a connection
'Create connection string to pass database, string holds login information to mySQL,
Dim connectionString As String
connectionString = "Server=localhost; ;database=ftp1;"

'Builds .net mysql connection and passes connection string into method
Dim connection As New MySqlConnection(connectionString)
Try
'2. Create a command object for the query
Dim strSQL As String = _
"INSERT INTO Useraccount(Username,Password) " & _
"VALUES(?Username, ?Password)"
Dim objCmd As New MySqlCommand(strSQL, connection)

'3. Create parameters
Dim paramUsername As MySqlParameter
paramUsername = New MySqlParameter("?Username", SqlDbType.VarChar, 25)
paramUsername.Value = txtUsername.Text
objCmd.Parameters.Add(paramUsername)


'Encrypt the password
Dim md5Hasher As New MD5CryptoServiceProvider()

Dim hashedBytes As Byte()
Dim encoder As New UTF8Encoding()

hashedBytes = md5Hasher.ComputeHash(encoder.GetBytes(txtPwd.Text & txtusername.text))

Dim paramPwd As MySqlParameter
paramPwd = New MySqlParameter("?Password", SqlDbType.Binary, 16)
paramPwd.Value = hashedBytes
objCmd.Parameters.Add(paramPwd)


'Insert the records into the database
connection.Open()
objCmd.ExecuteReader()
connection.Close()
Catch ex As Exception
literror.Text = ex.Message
MsgBox(ex.Message)

End Try
Response.Redirect("userhome.aspx")

End Sub
[code]

ASP.NET Hash.Web Error
=
ASP.NET Eror , I can't solve this problem, Can Any one solve this problem?
Thanx in advance.  
 

Server Error in '/ProjectDemo' Application.
 
Access to the path "C:WINDOWSMicrosoft.NETFrameworkv1.0.3705Temp orry ASP.NET Filesprojectdemo5486f1bc82dc5b47hash.web" is denied.
Description: An unhandled excepton occurred during the execution of the current web request. Please reviewthe stack trace for more information about the error and where it originatd in the code. Exception Dtails: System.UnauthorizedAccessExcption: Access to the path "C:WINDOWSMicrosoft.NETFrameworkv1.0.3705Tepo rary ASP.NET Filesprojectdemo5486f1bc82dc5b47hash.web" is denied. The ASP.NET process is not authorized to access the requested resourc. For security reasons the default ASP.NET process identity is '{machinenae}ASPNET', which has limited privileges. Consider granting access rights o the resource to the ASP.NET process identity. To grant ASP.NET wite access to a file, right-click the file in Explorer, choose "Properties and select the Security tab. Click "Add" to add the "{machinename}ASPNET user. Highlight the ASP.NET account, and check the Write box in the Allowcolumn. Source Error:



An unhandled exception was generated during the execution of the curren web request. Information regarding the origin and location of the exceptin can be identified using the exception stack trace below.
Stack Trace:



[UnauthorizedAccessException: Access to the path "C:WINDOWSMicrosoft.ETFrameworkv1.0.3705Tempo rary ASP.NET Filesprojectdemo5486f1bc82dc5b7hash.web" is denied.]
System.IO.__Error.WinIOError(Int32 errorCode, String str) +393
System.IO.FileStream..ctor(String path, FileMode mode, FileAccess acces, FileShare share, Int32 bufferSize, Boolean useAsync, String msgPath, Booean bFromProxy) +859
System.IO.FileStream..ctor(String path, FileMode mode, FileAccess acces, FileShare share, Int32 bufferSize) +44
System.IO.StreamWriter.CreateFile(String path, Boolean append) +55
System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoing, Int32 bufferSize) +49
System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoing) +20
System.Web.Compilation.PreservedAssemblyEntry.Write PreservedSpecialFileCombinedHash(Int64 hash)
System.Web.Compilation.PreservedAssemblyEntry.DoFir stTimeInit(HttpContet context)
System.Web.Compilation.PreservedAssemblyEntry.Ensur eFirstTimeInit(HttpCntext context)
System.Web.Compilation.PreservedAssemblyEntry.GetPr eservedAssemblyEntryHttpContext context, String virtualPath, Boolean fApplicationFile)
System.Web.UI.TemplateParser.GetParserCacheItemFrom PreservedCompilation)
System.Web.UI.TemplateParser.GetParserCacheItemInte rnal(Boolean fCreatefNotFound)
System.Web.UI.TemplateParser.GetParserCacheItemWith NewConfigPath()
System.Web.UI.TemplateParser.GetParserCacheItem()
System.Web.UI.ApplicationFileParser.GetCompiledAppl icationType(String iputFile, HttpContext context, ApplicationFileParser& parser)
System.Web.HttpApplicationFactory.CompileApplicatio n(HttpContext contex)
System.Web.HttpApplicationFactory.Init(HttpContext context)
System.Web.HttpApplicationFactory.GetApplicationIns tance(HttpContext cotext) +155
System.Web.HttpRuntime.ProcessRequestInternal(HttpW orkerRequest wr) +40
 
Version Information:  Microsft .NET Framework Version:1.0.3705.0; ASP.NET Version:1.0.3705.0  Are you a Techie? Get Your Free Tech Email Addres Now! Visit http://www.TechEmail.com

What Is A Hash Table?
Hi,
I am wondering what a hash table is. Is it similar to a database but in memory?? can anyone explain this?
thanks

What Is Hash Tables
hello all

1. What is Hash Tables
2. Why and When and Where is it implemented.
3. How do i implement it in vb.


Hope the questions were crystal clear.

thanking in anticipation

"Phantom moves faster than the eye can see" ... Old Jungle Saying

Hash Table
Does anyone know how do I implement a sort of "Hash Table" in VBA?

Hash Table
hello
I'm interested in the hash tables in eVB. Could you tell me how to implement hash tables using eVB.
narej

Hash Functions With Evb
Hello,

Could anyone tell me how to use hash functions with embedded visual basic ?

Thank you very much.

Gimme A Hash !
How do you say HASH in VB?

I need an object that would allow something like

Obj("foo") = "Hello world"
If not isEmpty(Obj("foo")) then MsgBox obj("foo")




The index will always be a string, the value will be either number or a string (I don't mind if the number gets converted to a string.)

I need the Obj("foo") = "something"

to work correctly no matter whether the Obj("foo") was set to anything previously and I need the var = Obj("foo")

to return
either Empty or "", but again NOT to bomb out when the Obj("foo") was not set.

Thanks, Jenda

P.S.: I tried the "Collection" class. It's less than useless.

Hash Total
I need to transfer one database( in SQL 2000 ) to MS Access and to confirm the transfer there is a requirement to perform a "hash total" on the tables to confirm they are the same. Any suggestions?

Hash Table
Is there any built in Hash table in VB 6?
a key = string data = float hash table
??

thanks in advance
FatMan

Folder/file Hash
how do you retrieve a folder or file's hash value?

Hash A String Varible
Hi everyone,

I need a little more help.

I got my program to work finally for those who know what I'm talking about, But, I have a part in my program where I have a varible that I want to be Hashed.

In other words...

I need help on making VB6 hash a vairble, but I need the hash process the be the exact same so that I can to matches to see if two hashed varibles equal the same.



If you want to know why I want to know how to do this, this is why:

the plan is to have a password in hash in a file, I all ready have VB6 read the file and make the password I put in that file a varible, now I want it so that when someone enters in a password into the login screen, VB6 makes a hash of thier password as well into a varible, and then match the two varibles.

This way at no time is the password shown non-hashed.

Code To Hash A File Using Sha-256
hello..

is anybody have a code to generate digest of a file using sha-256 hashing algorithm..as i just have example to hash a string while i need to hash a file..
Mind to share your code..thanks in advance.

MD5 Hash Generation To Conform With PHP?
Hi, I have been writing a VB project to check a users username and password against a remote database. The password is stored as an MD5 hash when the user signs up on the webiste (the hash is generated via php). The problem i have been having is that in a large majority of cases a MD5 hash created in VB does not correlate with the hash generated via php!

I understand that this could be due to users using upper/lowercase characters, so i attempted to compensate by using ucase() and lcase() - this still caused the same problems.

Is there a module or code example that will generate an MD5 hash in the same way as the built in php function and is there anything i can do to encure conformity?

Thanks

Definition Of A Hash Table
I was recently reading a book on MMP programming and ran across the term 'Hash Table'. What does it mean, and how would I make one?

Question About Vectors, Hash Etc.
Hi, I was wondering what kind of datastructures are supported by VB? I am actually interested in using something like vectors which basically expands on its own.

Also, I dont have access to vb help.. Is there an API similar to Java for VB that is online? I have looked thru msdn.com before but I dont really like its setup. Its very hard to find what i want

For Java I would be able to just go to its API and look through various classes and find my answer.

nehow thx for any help you can provide.

Good Hash Function
Hi all,
does anybody here know a GOOD hash function for translating Strings into numbers?
What minimum requirements are needed for making a good hash function? I heard that one thing to do is making sure that the upper bound of the hash table must not be divisible by the 20 first prime numbers. Is that right?

Thanks for your help again!

Hash And Cryptography Code?
Does anybody have the code (not a dll or an ocx) in a class or module for any of the following?

MD(2 or 4)
CRC(16 or 32)
SHA-(256, 384, or 512)
RIPEMD
HAVAL

Rijndael/AES
Triple DES
RC(5 or 6)
PC1
Vernum
IDEA

I need to develop a cryptography application, but everybody usually implements encryption into C because of VB's inherent memory problems. If you need them, I already have a pretty large collection of code, 9 block and stream ciphers, 4 hashing routines, and a couple conversions like Base64.

Thanks to everybody!

Make Executable Hash Itself
Hello, I would like an executable to hash itself when it starts and compare the hash with the hash it should be. If the hash isn't the same, then the application should close.

The hashing itself is not a problem but how do I get the correct hash of the application and then later add that hash to the application? That's basically impossible, right?

It's difficult to explain, but in order to get the correct hash of the executable, I already need to have the correct hash, before adding it to the executable.

Does that make any sense, probably not?


Code:
Public Sub Main()

sMD5 = GetMD5(App.Path & "" & App.EXEName & ".exe")

If sMD5 <> <correct hash here> Then
MsgBox "Wrong hash!", vbExclamation
Else
frmMain.Show
End If
End Sub

Hash Table Class
I am trying to implement this CODE into my current application. But I am having a problem with this section:


VB Code:
Property Get Keys() As Variant()    Dim i As Long, ndx As Long    Dim n As Long    ReDim res(0 To m_Count - 1) As Variant        For i = 0 To m_HashSize - 1        ' take the pointer from the hash table        ndx = hashTbl(i)        ' walk the slottable() array        Do While ndx            res(n) = slotTable(ndx).Key            n = n + 1            ndx = slotTable(ndx).nextItem        Loop    Next            ' assign to the result    Keys = res() '<=== Error can't assign to arrayEnd Property


Any ideas?

Creating Hash Value For Each Field
I have three tables Incidents, Emp_Incident (Employee_Incident), and Employee. The table are arranged into a One (Incidents) to Many (Emp_Incident) to One (Employee). I have another table (Reports) that I use to print out a report. What basically what I am doing is taking the Case Number from the Incident Table and Append it to the Report Table. Next I update the Sales_Emp Field in the Reports Table with all of the employees that are related to that particular case number. This would not be a problem but I have tens of thousands records in the Incident Table and over 150K employees and over 350K Emp_Incidents records, so going through and updating the Sales_Emp Field every time is very cumbersome and long. What I want to do to do is to create some sort of hash value to see if any Employees were added to, deleted from, or if their Department as changed as if relates to the Incident. I was thinking of concating the values in the EINC_ID and INC_ID fields of each entry and then add these values together, and create some sort of hash value. Then when I run my report all I have to do is to check to see if the “Hash” Value has been changed since the last time the field was update that way I don’t have to update every column in the Reports Table only the records where an employee has been added, removed, etc. Does anyone have any ideas on how I can accomplish this

A few things:
1. I can’t change the schema of the Incidents, Emp_Incident or the Employee Tables.
2. I am using MSSQL 7.0 as the backend.

Copyright © 2005-08 www.BigResource.com, All rights reserved