Sign in to follow this  
Followers 0

_UniCode UDF

12 posts in this topic

Posted (edited)

Hi,

i wrote this function to get a unique code of a pc.

Updated it and changed the name :D

Here is the code:

Func _UniquePCCode()
    Local $return , $first
    Local $pass = @ComputerName
    $encrypt = _Stringencrypt( 1 , $pass , $pass ) & @OSLang & @OSTYPE & @OSVersion & @OSServicePack & DriveGetSerial("C:\")
    $split = StringSplit( $encrypt , "a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z" )
    For $a = 1 to $split[0]
        For $b = 65 to 90
            If StringInStr( $split[$a] , Chr($B) ) Then
                $split[$a] = StringReplace( $split[$a] , Chr($B), $b )
            EndIf
        Next
        $first &= $split[$a]
    Next
    StringStripWS( $first , 8 )
    $split1 = StringSplit( $first , "_" )
    For $d = 1 to $split1[0]
        $return &= $split[$d]
    Next
    $return = StringMid(  $return ,  StringLen( $return ) / 2 - 3 , 8 )
    $second = Hex($return)
    $return = ""
    $split = StringSplit( $second , "a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z" )
    For $a = 1 to $split[0]
        For $b = 65 to 90
            If StringInStr( $split[$a] , Chr($B) ) Then
                $split[$a] = StringReplace( $split[$a] , Chr($B), $b )
            EndIf
        Next
        $return &= $split[$a]
    Next
    $return = StringMid(  $return ,  StringLen( $return ) / 2 - 3 , 8 )
    Return $return
EndFunc   ;==>_UniquePCCode

Note you need _stringencrypt from string.au3 for it.

Regards

Edited by Daniel W.

Share this post


Link to post
Share on other sites



Posted

That's a terribly mis-leading name since there already is a term "unicode" in computing.

Share this post


Link to post
Share on other sites

Posted

narg is this a problem?

I can change the name if you want but i though unicode for uniquecode is no problem...

Share this post


Link to post
Share on other sites

Posted

So you need me to coerce you into changing the name? The fact that the term has a previous and highly widespread (as in global) definition is not a sufficient reason to stop using the term out of context?

Share this post


Link to post
Share on other sites

Posted

I updated it and changed the name

Share this post


Link to post
Share on other sites

Posted

I noticed you are trimming white space " " using StringReplace(). Maybe you could try to use StringTrimWS() as it may be slightly faster.

JS

Share this post


Link to post
Share on other sites

Posted

Done :D Thanks for the tip

Share this post


Link to post
Share on other sites

Posted

Done :D Thanks for the tip

NP Glad I could offer some possible help.

I havent seen anything else yet that may help.

JS

Share this post


Link to post
Share on other sites

Posted (edited)

Shortened again :D

Replaced this:

Do 
           $return = StringTrimLeft( $return , 1 ) 
           If StringLen( $return ) > 8 Then 
                $return = StringTrimRight( $return , 1 ) 
           EndIf 
      Until StringLen( $return ) = 8
oÝ÷ Ùh­Øb±«­¢+Ø(ÀÌØíÉÑÕɸôMÑÉ¥¹5¥ ÀÌØíÉÑÕɸ°MÑÉ¥¹1¸ ÀÌØíÉÑÕɸ¤¼È´Ì°à¤
Edited by Daniel W.

Share this post


Link to post
Share on other sites

Posted (edited)

nice work guys, I like it, this will come in handy

Edited by ReaImDown

Share this post


Link to post
Share on other sites

Posted

Hi,

shortened a little bit and made it useable even if there is no drive c:\

Func _UniquePCCode1()
    Local $return, $first
    $split = StringSplit(_StringEncrypt(1, @ComputerName, @ComputerName) & _
            @OSLang & @OSTYPE & @OSVersion & @OSServicePack & DriveGetSerial(StringLeft(@WindowsDir, 3)), _
            "a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z")
    For $a = 1 To $split[0]
        For $b = 65 To 90
            If StringInStr($split[$a], Chr($B)) Then
                $split[$a] = StringReplace($split[$a], Chr($B), $B)
            EndIf
        Next
        $first &= $split[$a]
    Next
    $split1 = StringSplit(StringStripWS($first, 8), "_")
    For $d = 1 To $split1[0]
        $return &= $split[$d]
    Next
    $split = StringSplit(Hex(StringMid($return, StringLen($return) / 2 - 3, 8)), _
            "a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z")
    $return = ''
    For $a = 1 To $split[0]
        For $b = 65 To 90
            If StringInStr($split[$a], Chr($B)) Then
                $split[$a] = StringReplace($split[$a], Chr($B), $B)
            EndIf
        Next
        $return &= $split[$a]
    Next
    Return StringMid($return, StringLen($return) / 2 - 3, 8)
EndFunc   ;==>_UniquePCCode1

So long,

Mega

Share this post


Link to post
Share on other sites

Posted

Hi,

shortened a little bit and made it useable even if there is no drive c:\

Func _UniquePCCode1()
    Local $return, $first
    $split = StringSplit(_StringEncrypt(1, @ComputerName, @ComputerName) & _
            @OSLang & @OSTYPE & @OSVersion & @OSServicePack & DriveGetSerial(StringLeft(@WindowsDir, 3)), _
            "a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z")
    For $a = 1 To $split[0]
        For $b = 65 To 90
            If StringInStr($split[$a], Chr($B)) Then
                $split[$a] = StringReplace($split[$a], Chr($B), $B)
            EndIf
        Next
        $first &= $split[$a]
    Next
    $split1 = StringSplit(StringStripWS($first, 8), "_")
    For $d = 1 To $split1[0]
        $return &= $split[$d]
    Next
    $split = StringSplit(Hex(StringMid($return, StringLen($return) / 2 - 3, 8)), _
            "a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z")
    $return = ''
    For $a = 1 To $split[0]
        For $b = 65 To 90
            If StringInStr($split[$a], Chr($B)) Then
                $split[$a] = StringReplace($split[$a], Chr($B), $B)
            EndIf
        Next
        $return &= $split[$a]
    Next
    Return StringMid($return, StringLen($return) / 2 - 3, 8)
EndFunc   ;==>_UniquePCCode1

So long,

Mega

even better, lol

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0