Pain Posted August 4, 2008 Share Posted August 4, 2008 (edited) Some days ago I found SkinnyWhiteGuy's rijndael algorithm and I found it very interesting. http://www.autoitscript.com/forum/index.php?showtopic=44581 My question is how do I generate a good key (256 bits) that is as unique as possible? I found a post by arcker in same topic where he used 32 random character from a to z (all lowercase) to generate a key. $encryptkey = "" for $i = 1 to 32 $encryptkey &= chr(Random(97,122,1)) Next I do know that upper and lowercase will give totally different results. So would the key be more unique if I use both upper- and lowercase and how about if I would add numbers too? I also found it was possible to have other characters like space, exclamation mark etc. Chr(Random(32,255,1)) would be pretty random I assume but it's not very easy to write something like ý(}¯`8""ɽ|n/ðÈ1tÌólH8¸?[zµ to decrypt it. Da58D71de9B372A3869e582D51697BfM is easier to write and should work as a key, if it's random or not I have no idea about, but for me it looks like it's random (for me arckers key also looks random...). SkinnyWhiteGuy replied back to arcker and said: Just as an aside, your key could be more "unique" by using 16 random Binary from 0 to F(15 in hex) I didn't understand exactly how he meant but maybe someone else do. Any example of how to make a unique key would be appreciated. Edited August 4, 2008 by Pain Link to comment Share on other sites More sharing options...
ptrex Posted August 5, 2008 Share Posted August 5, 2008 @Pain this might get you started. $TypeLib = ObjCreate("Scriptlet.TypeLib") $strGUID = $TypeLib.Guid MsgBox(0,"Create GUID",$strGUID,5) regards ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
Pain Posted August 5, 2008 Author Share Posted August 5, 2008 thnx, I love you Link to comment Share on other sites More sharing options...
Renee Posted December 23, 2008 Share Posted December 23, 2008 @ptrex Thanks!!! that's what I was looking for. Link to comment Share on other sites More sharing options...
Zinthose Posted December 23, 2008 Share Posted December 23, 2008 In addition, If you want to avoid objects and rely on the Windows API you can also use: #Include <WinAPI.au3> MsgBox(4096, "Generate Guid", _CreateGuid()) Func _CreateGuid() Local $Guid = DllStructCreate($tagGUID) $Result = DllCall("OLE32.DLL", "dword", "CoCreateGuid", "ptr", DllStructGetPtr($Guid)) $Result = _WinAPI_StringFromGUID(DllStructGetPtr($Guid)) Return $Result EndFunc Cheers! --- TTFN Link to comment Share on other sites More sharing options...
Zinthose Posted December 23, 2008 Share Posted December 23, 2008 FYI I did a Speed/Stress test to compare the Speeds of Windows API verses the the Scriptlet.TypeLib method and came up with these results:Windows API = 934.094696392977 msScriptlet.TypeLib = 9680.83178169292 msThe Windows API was actually 10.36 times faster on my system. I was surprised about the large disparity actually. Sure, I expected the API to be faster but not this fast.I altered my tests to see how creating the TypeLib object and opening the DLL reference prior to the loops effects the results.Windows API = 896.096012202668 msScriptlet.TypeLib = 97.131898048495 msInteresting... Windows API only gained a minor improvement. However the TypeLib object's improvement was so astounding that it is now 97.13 times faster than the Windows API calls.So at this point... it's all in how you want to code your project. Speed or Memory Footprint.Code I used to test...expandcollapse popup#Include <WinAPI.au3> Const $MaxTest = 10000 Dim $TypeLib = ObjCreate("Scriptlet.TypeLib") Dim $i = 0, _ $Start = 0, _ $Results_API, _ $Results_Obj MsgBox(4096, "Generate Guid", _CreateGuid()) ;## Stress Test WinAPI $Start = TimerInit() $OLE32 = DllOpen("OLE32.DLL") For $i = 1 to $MaxTest _CreateGuid($OLE32) Next DllClose($OLE32) $Results_API = TimerDiff($Start) ;## Stress Test Object $Start = TimerInit() Dim $TypeLib = ObjCreate("Scriptlet.TypeLib") For $i = 1 to $MaxTest _CreateGuid2() Next $TypeLib = 0 $Results_Obj = TimerDiff($Start) ;## And the results ConsoleWrite( _ "Windows API = " & $Results_API & " ms" & @CRLF & _ "Scriptlet.TypeLib = " & $Results_Obj & " ms" & @CRLF _ ) Func _CreateGuid($DLL = "") Local $Guid = DllStructCreate($tagGUID) $Result = DllCall($DLL, "dword", "CoCreateGuid", "ptr", DllStructGetPtr($Guid)) $Result = _WinAPI_StringFromGUID(DllStructGetPtr($Guid)) Return $Result EndFunc Func _CreateGuid2() ;$TypeLib = ObjCreate("Scriptlet.TypeLib") $strGUID = $TypeLib.Guid Return $strGUID EndFunc --- TTFN Link to comment Share on other sites More sharing options...
liteswap Posted December 23, 2008 Share Posted December 23, 2008 Can I just say that the word 'unique' means there's only one of something? Nothing can be 'more unique' - something's either unique or it isn't. Sorry for the mini-rant but this one drives me crazy.... Link to comment Share on other sites More sharing options...
ProgAndy Posted December 23, 2008 Share Posted December 23, 2008 GUIDs aren't really unique. But creating the same number twice happens really rarely (i think till now, this didn't happen) *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes Link to comment Share on other sites More sharing options...
Zinthose Posted December 23, 2008 Share Posted December 23, 2008 GUIDs aren't really unique. But creating the same number twice happens really rarely (i think till now, this didn't happen)"GUID" is an acronym for Globally Unique IDentifier. So, yell at the guy who coined the acronym as he obviously has no background in statistics.Thanks WikipediaFYI: This is my lame attempt at humor --- TTFN Link to comment Share on other sites More sharing options...
werter Posted December 23, 2008 Share Posted December 23, 2008 pain is gone .. ok but as you are reading this topic --> i suppose i give you a little help with that: what makes a code or numer unique is the order of possible vallues a place in the code can take. like you have a code that is 4 terms long like : 1234 or 5555 or 0003 and you only can take numbers from 0 to 5 you will have 5 options on the first spot, 5 on the nextand another 5 options on the last spot. That makes 6*6*6*6 posibble codes ( = 6^4 ) so if you are using only letters (like a , b , c ... z ) that makes you wich the basis on 6^4 and gives 26^4 the results are ranging from aaaa to zzzz ok now the result : if the couple of singel parts i can mix or choose for each place is bigger the more possible combinations i can make. Some possible system you could take as basis. short list: binary : 0 or 1 just numbers: 0 1 2 3 4 5 6 7 8 9 from aboth HEX ( btw 16 not 15 ): 0 1 2 3 4 5 6 7 8 9 A B C D E F e.g.: 47c85c could be a funny green in html just letters: a b c d .... x y z etc etc Link to comment Share on other sites More sharing options...
Pain Posted December 24, 2008 Author Share Posted December 24, 2008 Thanks I already got the answer I was looking for some time ago but thanks anyways. Link to comment Share on other sites More sharing options...
MilesAhead Posted December 25, 2008 Share Posted December 25, 2008 "GUID" is an acronym for Globally Unique IDentifier. So, yell at the guy who coined the acronym as he obviously has no background in statistics.Thanks WikipediaFYI: This is my lame attempt at humorSomeone I know attended a seminar on some MS Programming subject. The lecturer had a PC running in the background all the time with this scroll going up the screen. When asked about it the lecturer said "Oh that! It just generates GUIDs 24/7. I'm trying to use them all up so MS will be screwed!!" My Freeware Page Link to comment Share on other sites More sharing options...
CodyBarrett Posted December 25, 2008 Share Posted December 25, 2008 lol can you say.. OWNED although from what you say... depending on the AMOUNT of digits, it could be limitless [size="1"][font="Tahoma"][COMPLETED]-----[FAILED]-----[ONGOING]VolumeControl|Binary Converter|CPU Usage| Mouse Wrap |WinHide|Word Scrammbler|LOCKER|SCREEN FREEZE|Decisions Decisions|Version UDF|Recast Desktop Mask|TCP Multiclient EXAMPLE|BTCP|LANCR|UDP serverless|AIOCR|OECR|Recast Messenger|AU3C|Tik-Tak-Toe|Snakes & Ladders|BattleShips|TRON|SNAKE_____________________[u]I love the Helpfile it is my best friend.[/u][/font][/size] Link to comment Share on other sites More sharing options...
Pain Posted December 25, 2008 Author Share Posted December 25, 2008 (edited) Some time ago (about the same time as when this topic was created) I made some research about GUID's. It looks like I finally got some use of that research now. @MilesAheadGood luck, you got 340,282,366,920,938,463,463,374,607,431,768,211,456 possible combinations for a GUID, and that's only 32 chars. (Same as a 128-bit password)To make it easier to understand this number there is: 6,740,000,000 human inhabitants as of November 2008 on Earth.7,500,000,000,000,000,000 sand grains on Earth.43,252,003,274,489,856,000 possible combinations on a Rubik's Cube.7,000,000,000,000,000,000,000,000,000 atoms in a human body.As you can see this is still nothing compared to the GUID's.(340,282,366,920,938,463,463,374,607,431,768,211,456)Let's say you want to generate all possible combinations and you can generate 1,000,000,000,000 combinations every nanosecond (one billionth of a second) it would still take 1,000,000,000 years for you. Now in the reality it's not possible to generate that many combinations. But let's say you got the worlds fastest super computer, the IMB Roadrunner, the result would look like this: 3.4 x 10^38 (combinations) -------------------------- ~ 3.4 × 10^23 seconds 1 x 10^15 (1 petaflop, one quadrillion floating point operations per second. Your computer can execute approximately 50-200 million floating point operations per second depending on the hardware.)3.4 × 10^23------------ ~ 1.07739499 × 10^16 years31557600 (sec on a average year with 365.25 days)1.07739499 × 10^16 = 10,773,949,900,000,000 yearsThat's 10 quadrillion years. (or billiard if you live in EU)The amount of space to store all these GUID's would be insane.... Edited December 25, 2008 by Pain Link to comment Share on other sites More sharing options...
CodyBarrett Posted December 25, 2008 Share Posted December 25, 2008 like i said inifite lol(close enough to be called infinet) [size="1"][font="Tahoma"][COMPLETED]-----[FAILED]-----[ONGOING]VolumeControl|Binary Converter|CPU Usage| Mouse Wrap |WinHide|Word Scrammbler|LOCKER|SCREEN FREEZE|Decisions Decisions|Version UDF|Recast Desktop Mask|TCP Multiclient EXAMPLE|BTCP|LANCR|UDP serverless|AIOCR|OECR|Recast Messenger|AU3C|Tik-Tak-Toe|Snakes & Ladders|BattleShips|TRON|SNAKE_____________________[u]I love the Helpfile it is my best friend.[/u][/font][/size] Link to comment Share on other sites More sharing options...
MilesAhead Posted December 29, 2008 Share Posted December 29, 2008 Some time ago (about the same time as when this topic was created) I made some research about GUID's. It looks like I finally got some use of that research now. @MilesAheadGood luck, you got 340,282,366,920,938,463,463,374,607,431,768,211,456 possible combinations for a GUID, and that's only 32 chars. (Same as a 128-bit password)To make it easier to understand this number there is: 6,740,000,000 human inhabitants as of November 2008 on Earth.7,500,000,000,000,000,000 sand grains on Earth.43,252,003,274,489,856,000 possible combinations on a Rubik's Cube.7,000,000,000,000,000,000,000,000,000 atoms in a human body.As you can see this is still nothing compared to the GUID's.(340,282,366,920,938,463,463,374,607,431,768,211,456)Let's say you want to generate all possible combinations and you can generate 1,000,000,000,000 combinations every nanosecond (one billionth of a second) it would still take 1,000,000,000 years for you. Now in the reality it's not possible to generate that many combinations. But let's say you got the worlds fastest super computer, the IMB Roadrunner, the result would look like this: 3.4 x 10^38 (combinations) -------------------------- ~ 3.4 × 10^23 seconds 1 x 10^15 (1 petaflop, one quadrillion floating point operations per second. Your computer can execute approximately 50-200 million floating point operations per second depending on the hardware.)3.4 × 10^23------------ ~ 1.07739499 × 10^16 years31557600 (sec on a average year with 365.25 days)1.07739499 × 10^16 = 10,773,949,900,000,000 yearsThat's 10 quadrillion years. (or billiard if you live in EU)The amount of space to store all these GUID's would be insane....Ah, I think they guy was doing it for a joke. My Freeware Page Link to comment Share on other sites More sharing options...
Xand3r Posted December 29, 2008 Share Posted December 29, 2008 (edited) the problem with randomized is that you don't really have to generate all the possibilities .. you just have to generate the same one twice! p.s: maybee you could do it with Blue Gene/Q Edited December 29, 2008 by TheMadman Only two things are infinite, the universe and human stupidity, and i'm not sure about the former -Alber EinsteinPractice makes perfect! but nobody's perfect so why practice at all?http://forum.ambrozie.ro Link to comment Share on other sites More sharing options...
Pain Posted December 29, 2008 Author Share Posted December 29, 2008 I know, but still if you generate 1,000,000,000 GUID's every sec for 100 years (24/7) it's still only 50% chance that you have generated the same GUID. So well I think we can say that a GUID is pretty unique. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now