Click here to Skip to main content
15,881,092 members
Articles / Programming Languages / Visual Basic

K3YK4Y String Hasher

Rate me:
Please Sign up or sign in to vote.
1.67/5 (2 votes)
18 Aug 2008CPOL 28.3K   106   7   5
Advanced/Not-So Advanced string and password hash.

Introduction

A quick and easy solution to encrypt passwords. Just like MD5, SHA1 etc., it creates a long, confusing, and half-pointless string of numbers that cannot be decrypted.

Unlike some hashes, there is no possible (yet) way to recreate the same hash without the same string (unless you are using basic encryption).

Using the code

There are only two classes in this, as you will find out. There are three different ways to encrypt a string: Basic, Effective, and Advanced (which should probably be ultra-unhackable).

VB
Public Class K3YK4Y
    Public Class encode
        Public Shared Function basic(ByVal str As String)
            'Possibly hackable, although not very likely. Would require a LOT of maths.
            Dim k3yk4y As Int32 = Nothing
            For Each number As Byte In Text.ASCIIEncoding.ASCII.GetBytes(str)
                k3yk4y += number
            Next
            Return k3yk4y
        End Function

        Public Shared Function effective(ByVal str As String)
            '9999/10000 chance of ever being hacked
            '9998/10000 if they know the formula
            Dim k3yk4y As Int32 = Nothing
            Dim order As String = Nothing
            For Each number As Byte In Text.ASCIIEncoding.ASCII.GetBytes(str)
                order &= Convert.ToInt64(number) / 4
                k3yk4y += number
            Next
            Return Convert.ToInt64(k3yk4y) & order
        End Function

        Public Shared Function advanced(ByVal str As String)
            'Lmao ;).
            Dim k3yk4y As String = Nothing
            Dim order As String = Nothing
            For Each number As Byte In Text.ASCIIEncoding.ASCII.GetBytes(str)
                order &= Convert.ToInt64(number) / 4
                k3yk4y &= Hex(number / 2)
            Next
            Dim orderLength As Int32 = order.Length / 2
            Dim halfOrder As String = order.Substring(orderLength, 4)
            Dim endEncode As Decimal = Convert.ToDecimal(halfOrder) * 2
            Return k3yk4y & order & endEncode
        End Function
    End Class
End Class

Each encryption level returns a different string with things added or taken off for more security. I guess you could use this process with files, but imagine how big it would be :S. Pretty pointless too, considering you can't decrypt it.

Points of interest

What I really like about what I've done here is all the little pointless things. They make it look big and confusing when all you really need to use is the basic encryption, and voila! Although, basic encryption does tend to return the same result if the strings use the same letters.

History

  • 2008-08-18: Version 1 released.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
United Kingdom United Kingdom
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
QuestionEncrypt it's okay..... but decrypt?? Pin
coccode14413-Mar-09 9:34
coccode14413-Mar-09 9:34 
GeneralCollision Pin
jzonthemtn18-Aug-08 14:27
jzonthemtn18-Aug-08 14:27 
GeneralRe: Collision Pin
trecool99918-Aug-08 16:46
trecool99918-Aug-08 16:46 
GeneralRe: Collision Pin
jzonthemtn19-Aug-08 7:50
jzonthemtn19-Aug-08 7:50 
GeneralRe: Collision Pin
trecool99919-Aug-08 7:51
trecool99919-Aug-08 7:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.