Connecting Tech Pros Worldwide Help | Site Map

Creating a unique number from a text string

Dixie
Guest
 
Posts: n/a
#1: Nov 13 '05
I am trying to create a registration system in which a unique text string
accessible in a table of the program is turned into a unique number which
will be matched with a number sent to the customer to type into the program
to reregister it. The idea is that this key will not work on another
program, only the one it is generated for.

My initial problem is how do I generate in code, a unique number from say a
3 word phrase with only letters of the alphabet in it.

dixie


Tom van Stiphout
Guest
 
Posts: n/a
#2: Nov 13 '05

re: Creating a unique number from a text string


On Wed, 26 Oct 2005 10:35:36 +1000, "Dixie" <dixie@dogmail.com> wrote:

There are many ways. For example you could turn each character's ASCII
code into a hex number:
A -> Hex$(Asc("A")) = 41
etc.
You can also look at something called Base-64, which was specifically
designed to turn any string into "easy" characters.

-Tom.

[color=blue]
>I am trying to create a registration system in which a unique text string
>accessible in a table of the program is turned into a unique number which
>will be matched with a number sent to the customer to type into the program
>to reregister it. The idea is that this key will not work on another
>program, only the one it is generated for.
>
>My initial problem is how do I generate in code, a unique number from say a
>3 word phrase with only letters of the alphabet in it.
>
>dixie
>[/color]

Dixie
Guest
 
Posts: n/a
#3: Nov 13 '05

re: Creating a unique number from a text string


Thanks Tom. I have done something with Base64 by using one of the free
online sites to encode the text into base64 and then copied the encoded text
into the program for a particular site. I have figured out how to do the
rest of the stuff I need to do to re-register the software. The one
improvement that would be really good is to have a module which could do the
base64 encoding itself within Access. Does anyone know of any such module
or another way of doing this?

dixie

"Tom van Stiphout" <no.spam.tom7744@cox.net> wrote in message
news:2cvtl1htkk8b7mk88nfr3blqcc2nsvjl9a@4ax.com...[color=blue]
> On Wed, 26 Oct 2005 10:35:36 +1000, "Dixie" <dixie@dogmail.com> wrote:
>
> There are many ways. For example you could turn each character's ASCII
> code into a hex number:
> A -> Hex$(Asc("A")) = 41
> etc.
> You can also look at something called Base-64, which was specifically
> designed to turn any string into "easy" characters.
>
> -Tom.
>
>[color=green]
>>I am trying to create a registration system in which a unique text string
>>accessible in a table of the program is turned into a unique number which
>>will be matched with a number sent to the customer to type into the
>>program
>>to reregister it. The idea is that this key will not work on another
>>program, only the one it is generated for.
>>
>>My initial problem is how do I generate in code, a unique number from say
>>a
>>3 word phrase with only letters of the alphabet in it.
>>
>>dixie
>>[/color]
>[/color]


lylefair
Guest
 
Posts: n/a
#4: Nov 13 '05

re: Creating a unique number from a text string


In VBA numbers are limited in size by the number of bytes used to store
them in memory. Unless on messes with variant decimals, 8 bytes seems
to be the maximum.
So it will be hard to represent a string of 47 bytes with a number
which can deal with only 8.
If you would like a number based on the first 8 bytes of the string, or
you would like to require an 8 character password/login then this
function (cobbled together over coffee and subject therefore to the
appelation, "Air Code") might help. I have used currency because it is
stored as 8 bytes and because it is simple, usually being displayed in
#.# and not scientific notation.

Option Explicit
Private Declare Sub CopyMemory _
Lib "kernel32" Alias "RtlMoveMemory" _
(Destination As Any, Source As Any, ByVal Length As Long)

Function CurrencyFromString(ByVal s As String) As Currency
s = s & String(8, vbNullChar)
s = Left(s, 8)
Dim a() As Byte
a = StrConv(s, vbFromUnicode)
CopyMemory CurrencyFromString, a(0), 8
End Function

Sub text()
Debug.Print CurrencyFromString("Dixie")
End Sub

Closed Thread