|
-
Jun 10th, 2008, 01:47 AM
#1
Thread Starter
^:^...ANGEL...^:^
[RESOLVED] Self Validating Number Generation
Hi,
Been a while since I have been here. I will rather jump to the point then chit chatting.
I need to create a self validating number. Does anyone here has an experience to create an algorithm to achieve such things? What sort of base data is required? e.g. Seed value which is used to generate a number or something like that.
Basicall I need to create a barcode number for users so they can scan the barcode rather than entring the username everytime (basically for auditing and tracing of files purposes).
So what I would like to do is create a unique barcode for each user that can be printed but upon scan the an application on the PDA Scanner should be able to varify that the number indeed is the correct one before sending it to the server for the database verification. This is much like Credit Card or Social Security Number or ABN/ACN/TFN (for those who live in Australia).
Does this all make any sense? Please let me know if anymore information is required.
Cheers
-
Jun 10th, 2008, 02:16 AM
#2
Re: Self Validating Number Generation
Is there a maximum name length in your situation?
If not can that be made a requirement?
Else it would be near impossible to keep te encryption fixed
And that's the clue, you need to look for encryption anyways
 why can't programmers keep and 31 Oct and 25 dec apart. Why Rating is Useful
for every question you ask provide an answer on another thread.
-
Jun 10th, 2008, 02:19 AM
#3
Thread Starter
^:^...ANGEL...^:^
Re: Self Validating Number Generation
I can make it maximum 12 characters if that is helpful?
-
Jun 10th, 2008, 02:41 AM
#4
Re: Self Validating Number Generation
Sure,
Now think about this:
the alfabet in lowercase and a few extra characters like whitespace
can be contained in 32 diffrent numbers
0-31.
You need 6 bits for this.
convert your string into a continious bit stream and
this into a decimal number
If you heve some patience I will make an example tonight (GMT +1)
 why can't programmers keep and 31 Oct and 25 dec apart. Why Rating is Useful
for every question you ask provide an answer on another thread.
-
Jun 10th, 2008, 06:10 AM
#5
Thread Starter
^:^...ANGEL...^:^
Re: Self Validating Number Generation
Hi there,
Thanks for the suggestion. Yeah I wouldn't mind looking at the example. At the moment I am taking a given date as a decimal value in SQL Server. Then getting a GUID and retrieving the ASCII of each character in the GUID and then adding it up and then finally multiplying the that number to the decimal value of the datetime.
Then I need to do something to convert that nice looking decimal number to 8 - 12 character.
Let's see how you are thinking about doing it?
-
Jun 10th, 2008, 03:27 PM
#6
Re: Self Validating Number Generation
Whilst writing it I Realized 5 bits per character would do.
Make a windows project with a Form => Form1
3 textboxes => TextBox1 to 3
And a Button => button1
Place the code in the form and enter a string in Textbox1
Code:
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim BinaryString As String = String.Empty
Dim Ch() As Char
'Convert the input
Ch = Me.TextBox1.Text.PadLeft(12, " ")
For Counter As Integer = 0 To Ch.Length - 1
BinaryString &= ReduceTo6BitString(Ch(Counter))
Next
'Display the output
Me.TextBox2.Text = BinaryString.Length
Me.TextBox3.Text = Convert.ToInt64(BinaryString, 2).ToString
End Sub
''' <summary>
''' Reduce input to upper chars or whitespace
''' </summary>
''' <param name="sender"></param>
''' <param name="e"></param>
''' <remarks></remarks>
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
If Char.IsLetter(e.KeyChar) Then
e.KeyChar = Char.ToUpper(e.KeyChar)
ElseIf Not (Char.IsWhiteSpace(e.KeyChar) Or Char.IsControl(e.KeyChar)) Then
e.Handled = True
End If
End Sub
''' <summary>
''' Convert the input to "Binary" strings with a length of 5
''' </summary>
''' <param name="Ch"></param>
''' <returns></returns>
''' <remarks></remarks>
Function ReduceTo6BitString(ByVal Ch As Char) As String
Dim CharValue As Integer
If Char.IsWhiteSpace(Ch) Then
ReduceTo6BitString = "00000"
Else
CharValue = Asc(Ch) - 64
ReduceTo6BitString = Convert.ToString(CharValue, 2).PadLeft(5, "0")
End If
End Function
End Class
Have Fun!
 why can't programmers keep and 31 Oct and 25 dec apart. Why Rating is Useful
for every question you ask provide an answer on another thread.
-
Jun 11th, 2008, 07:24 AM
#7
Thread Starter
^:^...ANGEL...^:^
Re: Self Validating Number Generation
Hey Dnereb, thanks for the quick solution code and your efforts.
Cheers
-
Jun 11th, 2008, 12:57 PM
#8
Re: [RESOLVED] Self Validating Number Generation
Thx! i realy appriciate feedback on my efforts!
BTW I just notice you're an Aussie, i'll be in Sydney and albury in october
if you do know any vacancies for a .Net programmer....
See Ya!
 why can't programmers keep and 31 Oct and 25 dec apart. Why Rating is Useful
for every question you ask provide an answer on another thread.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|