| re: Scrambling text to create a unique identifier
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Could try the ole XOR trick (use debug window):
The seed is "z" - turns "A," Chr$(65), into Chr$(59), semi-colon.
? asc("A") xor asc("z")
59
Use the seed on the "converted" character to get the original
? asc("z") xor 59
65
Use a loop to convert a string to an "encrypted" string:
Function encrypt(str As String)
Const strSeed = "z"
Dim i As Integer
Dim strEncrypt As String
For i = 1 To Len(str)
strEncrypt = strEncrypt & _
Chr$(Asc(Mid$(str, i, 1)) Xor Asc(strSeed))
Next i
encrypt = strEncrypt
End Function
Usage:
' encrypt
str = "abcde"
debug.print encrypt(str) ' -> yields 5 square chars
' decrypt - str now holds encrypted string
debug.print encrypt(str) ' -> yields "abcde"
--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)
-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv
iQA/AwUBQiaTCYechKqOuFEgEQJJNwCglWCeyC70vfJzP7dZiiXTXG n4LM0An1lD
iG0zhVE84S8mCkNgYjNd7BJt
=oIPq
-----END PGP SIGNATURE-----
MLH wrote:[color=blue]
> I have a 50-char job name field (text type) in an Access
> table. The entries into this field will be unique. No two
> records will house the same job name.
>
> I would like an algorithm that would churn out an 8-char
> (A-Z domain) unique text code based on the seed value
> provided by the unique input string contained in the job
> name field. I'm not looking for 128-bit encryption tech-
> nology here - just something the average secretary type
> user wouldn't likely be able to unscramble on her coffee
> break. Was hoping to do this with Access Basic in an
> Access 2.0 application.
>
> Most important to me is that unique job name strings be
> scrambled into correspondingly unique 8-char ID codes.
> I wouldn't want the following 2 job names to somehow
> be resolved to the same code...
>
> "Renovation for the McCoy residence"
> "Renovation for he Hatfield log cabin"
>
> So, there it is. Ideas? Solutions?[/color] |