cypher

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Trevor2007
    New Member
    • Feb 2008
    • 68

    cypher

    I would like to create a registration # for my db so after the trial period has expired the user must enter the registration #.
    to do this I would like to get 2 unique values from the pc
    posable the Mac address from the motherboard, and I think every processor has an adress or serial # that is uniqe to it(correct me if im wrong)
    and with those 2 vaules perform a cypher on them and add the 2 cypers together.

    so how to get those 2 values using VBA? and then how do I create my cypher (Ie: A cold = 1) ,(lower case e = capitale Z), in my example my cypher isn't realy thaught out as to the algarythem but you have the idea if you don't know what a cypher is. a cypher is an algarythm that when appied increment or dincremnets the origonal value to algarythm of the chyper
    for the end user to get this registration code , I would have the generator that would then give me the correct values to tell the user to enter.
    thanks for helping
  • mshmyob
    Recognized Expert Contributor
    • Jan 2008
    • 903

    #2
    Here is the code to get the MAC address. I would not suggest trying to get the CPU serial number only because you cannot get it from every machine (it can be disabled) so it would not be reliable.

    You could get the MAC address and then do a CRC checksum on it and create a unique number and use that as your registration code.

    I did that years ago in DOS Basic so I would need to take some time to work out the CRC in VBA.

    Any ways here is the MAC address code.

    [code=vba]
    Option Compare Database
    Option Explicit

    Private Const NCBASTAT = &H33
    Private Const NCBNAMSZ = 16
    Private Const HEAP_ZERO_MEMOR Y = &H8
    Private Const HEAP_GENERATE_E XCEPTIONS = &H4
    Private Const NCBRESET = &H32

    Private Type NCB
    ncb_command As Byte 'Integer
    ncb_retcode As Byte 'Integer
    ncb_lsn As Byte 'Integer
    ncb_num As Byte ' Integer
    ncb_buffer As Long 'String
    ncb_length As Integer
    ncb_callname As String * NCBNAMSZ
    ncb_name As String * NCBNAMSZ
    ncb_rto As Byte 'Integer
    ncb_sto As Byte ' Integer
    ncb_post As Long
    ncb_lana_num As Byte 'Integer
    ncb_cmd_cplt As Byte 'Integer
    ncb_reserve(9) As Byte ' Reserved, must be 0
    ncb_event As Long
    End Type
    Private Type ADAPTER_STATUS
    adapter_address (5) As Byte 'As String * 6
    rev_major As Byte 'Integer
    reserved0 As Byte 'Integer
    adapter_type As Byte 'Integer
    rev_minor As Byte 'Integer
    duration As Integer
    frmr_recv As Integer
    frmr_xmit As Integer
    iframe_recv_err As Integer
    xmit_aborts As Integer
    xmit_success As Long
    recv_success As Long
    iframe_xmit_err As Integer
    recv_buff_unava il As Integer
    t1_timeouts As Integer
    ti_timeouts As Integer
    Reserved1 As Long
    free_ncbs As Integer
    max_cfg_ncbs As Integer
    max_ncbs As Integer
    xmit_buf_unavai l As Integer
    max_dgram_size As Integer
    pending_sess As Integer
    max_cfg_sess As Integer
    max_sess As Integer
    max_sess_pkt_si ze As Integer
    name_count As Integer
    End Type
    Private Type NAME_BUFFER
    name As String * NCBNAMSZ
    name_num As Integer
    name_flags As Integer
    End Type
    Private Type ASTAT
    adapt As ADAPTER_STATUS
    NameBuff(30) As NAME_BUFFER
    End Type

    Private Declare Function Netbios Lib "netapi32.d ll" _
    (pncb As NCB) As Byte
    Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMem ory" ( _
    hpvDest As Any, ByVal hpvSource As Long, ByVal cbCopy As Long)
    Private Declare Function GetProcessHeap Lib "kernel32" () As Long
    Private Declare Function HeapAlloc Lib "kernel32" _
    (ByVal hHeap As Long, ByVal dwFlags As Long, _
    ByVal dwBytes As Long) As Long
    Private Declare Function HeapFree Lib "kernel32" (ByVal hHeap As Long, _
    ByVal dwFlags As Long, lpMem As Any) As Long


    ' button ONCLICK event
    Private Sub cmdGetMAC_Click ()
    Dim myNcb As NCB
    Dim bRet As Byte
    myNcb.ncb_comma nd = NCBRESET
    bRet = Netbios(myNcb)

    myNcb.ncb_comma nd = NCBASTAT
    myNcb.ncb_lana_ num = 0
    myNcb.ncb_calln ame = "* "

    Dim myASTAT As ASTAT, tempASTAT As ASTAT
    Dim pASTAT As Long
    myNcb.ncb_lengt h = Len(myASTAT)
    Debug.Print Err.LastDllErro r
    pASTAT = HeapAlloc(GetPr ocessHeap(), HEAP_GENERATE_E XCEPTIONS _
    Or HEAP_ZERO_MEMOR Y, myNcb.ncb_lengt h)
    If pASTAT = 0 Then
    Debug.Print "memory allcoation failed!"
    Exit Sub
    End If
    myNcb.ncb_buffe r = pASTAT
    bRet = Netbios(myNcb)
    Debug.Print Err.LastDllErro r
    CopyMemory myASTAT, myNcb.ncb_buffe r, Len(myASTAT)
    MsgBox Hex(myASTAT.ada pt.adapter_addr ess(0)) & " " & _
    Hex(myASTAT.ada pt.adapter_addr ess(1)) _
    & " " & Hex(myASTAT.ada pt.adapter_addr ess(2)) & " " _
    & Hex(myASTAT.ada pt.adapter_addr ess(3)) _
    & " " & Hex(myASTAT.ada pt.adapter_addr ess(4)) & " " _
    & Hex(myASTAT.ada pt.adapter_addr ess(5))
    HeapFree GetProcessHeap( ), 0, pASTAT
    End Sub
    [/code]

    Create a form with a button called 'cmdGetMac' and click on it.


    cheers,

    Originally posted by Trevor2007
    I would like to create a registration # for my db so after the trial period has expired the user must enter the registration #.
    to do this I would like to get 2 unique values from the pc
    posable the Mac address from the motherboard, and I think every processor has an adress or serial # that is uniqe to it(correct me if im wrong)
    and with those 2 vaules perform a cypher on them and add the 2 cypers together.

    so how to get those 2 values using VBA? and then how do I create my cypher (Ie: A cold = 1) ,(lower case e = capitale Z), in my example my cypher isn't realy thaught out as to the algarythem but you have the idea if you don't know what a cypher is. a cypher is an algarythm that when appied increment or dincremnets the origonal value to algarythm of the chyper
    for the end user to get this registration code , I would have the generator that would then give me the correct values to tell the user to enter.
    thanks for helping

    Comment

    • Trevor2007
      New Member
      • Feb 2008
      • 68

      #3
      Thanks for the code, sorry it took me a while to get back to you,
      I can't tell by looking at it if it gets the MAC addresss and performs the crc check, or if it just gets the Mac Address?
      I would like to display the Mac in a textbox for testing, whet line of the core is the reulting Mac, it would be easyer for me if your code was commented :-p
      The mesgbox is only displaying 6 0's
      thanks.

      Comment

      • Trevor2007
        New Member
        • Feb 2008
        • 68

        #4
        Im Always getting 6 0's in the messagebox , mnd does code perform a crc check or just return the MAC( getting lost reading the code)

        Comment

        • Trevor2007
          New Member
          • Feb 2008
          • 68

          #5
          I was able to get Cpu ID and motherboard serial by re working some vbscripts I had so they would work in my access Db(not hard) but with out testing them in a corperate enviroment, I have 1 question( I'll be able to hopefully test them monday) how likly is it for 2 pcs in an office setting to have the same cpu ID and motherboard serial (knowing companies buy the same computer configuratian several times over (yes I know the #'s are suposedly uniqe but I've been reading and some manufacture don't have cpu ID's or they use the same ID # as a modle # and it will come up as an ID #)?

          Comment

          • mshmyob
            Recognized Expert Contributor
            • Jan 2008
            • 903

            #6
            Could you post your complete code so I can see. this has always worked for me and still does.

            It does not include the CRC check.

            cheers,

            Originally posted by Trevor2007
            Im Always getting 6 0's in the messagebox , mnd does code perform a crc check or just return the MAC( getting lost reading the code)

            Comment

            Working...