Using FreeSpace as a randomizer or password generator

User avatar
ChrisGreaves
PlutoniumLounger
Posts: 15635
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

Using FreeSpace as a randomizer or password generator

Post by ChrisGreaves »

I'm thinking that the number of free bytes on a set of drives is a reasonable randomizer for occasional use, once or twice a day.
I think that the time of day (to a fraction of a second) is still a better randomizer for an end-user event such as generating a password.

In the self-testing function below i total the free bytes available on
(1) My BigBeigeBox drive D:
(2) The system drive on this NetBook
(3) The data partition on this NetBook.

I've seen a reference within the past month of an internet-source that offers a signal from random atmospheric(?)/astronomical(?) sources

Code: Select all

Declare Function GetDiskFreeSpaceEx Lib "kernel32" _
    Alias "GetDiskFreeSpaceExA" _
    (ByVal lpcurRootPathName As String, _
    lpFreeBytesAvailableToCaller As Currency, _
    lpTotalNumberOfBytes As Currency, _
    lpTotalNumberOfFreeBytes As Currency) As Long

Function lngFreeBytes(NetworkShare As String) As Long
    '' Cloned from code at http://www.pcreview.co.uk/forums/network-drive-free-space-t2381085.html
    '' Doug Steele, Microsoft Access MVP; http://I.Am/DougSteele; (no e-mails, please!)
    Dim curBytesFreeToCaller As Currency
    Dim curTotalBytes As Currency
    Dim curTotalFreeBytes As Currency
    Call GetDiskFreeSpaceEx(NetworkShare, curBytesFreeToCaller, curTotalBytes, curTotalFreeBytes)
    lngFreeBytes = curTotalFreeBytes
'Sub TESTFreeBytes()
'    Debug.Print lngFreeBytes("\\Bbb\d") + lngFreeBytes("C:") + lngFreeBytes("T:")
'End Sub
End Function
There's nothing heavier than an empty water bottle

User avatar
Sundog
5StarLounger
Posts: 704
Joined: 28 Jan 2010, 22:47
Location: Alien Country (Roswell NM)

Re: Using FreeSpace as a randomizer or password generator

Post by Sundog »

Sundog

User avatar
ChrisGreaves
PlutoniumLounger
Posts: 15635
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

Re: Using FreeSpace as a randomizer or password generator

Post by ChrisGreaves »

Sundog wrote:Maybe this: http://www.random.org/passwords/?
That's the one! Thanks, Sundog.
It is web-based, so short of some nifty Excel-VA to dl the page and extract the number ...
I suspect for my purposes a time-of-day PLUS free space is sufficiently random, though, right?
There's nothing heavier than an empty water bottle

User avatar
StuartR
Administrator
Posts: 12612
Joined: 16 Jan 2010, 15:49
Location: London, Europe

Re: Using FreeSpace as a randomizer or password generator

Post by StuartR »

ChrisGreaves wrote:...
I suspect for my purposes a time-of-day PLUS free space is sufficiently random, though, right?
Depending on what you need this for, then the milliseconds part of time of day, combined with the least significant few digits of free space may make a reasonable seed for your random number generator.
StuartR


User avatar
ChrisGreaves
PlutoniumLounger
Posts: 15635
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

Re: Using FreeSpace as a randomizer or password generator

Post by ChrisGreaves »

StuartR wrote:... combined with the least significant few digits of free space
Thanks Stuart.
Or maybe the last 3 digits of Available memory (although I suspect the original figure will always be a multiple of 4,096 bytes)

Code: Select all

' http://www.java2s.com/Code/VBA-Excel-Access-Word/Windows-API/GetSystemMemorySize.htm
Declare Sub abGlobalMemoryStatus Lib "kernel32" Alias "GlobalMemoryStatus" (lpBuffer As MEMORYSTATUS)
Type MEMORYSTATUS
   dwLength As Long
   dwMemoryLoad As Long
   dwTotalPhys As Long
   dwAvailPhys As Long
   dwTotalPageFile As Long
   dwAvailPageFile As Long
   dwTotalVirtual As Long
   dwAvailVirtual As Long
End Type
Function lngAvailableMemory() As Long
    Dim MS As MEMORYSTATUS
    'Set the length member before you call GlobalMemoryStatus
    MS.dwLength = Len(MS)
    Call abGlobalMemoryStatus(MS)
    lngAvailableMemory = MS.dwAvailPhys
'Sub TESTlngAvailableMemory()
'    Debug.Print Format(lngAvailableMemory, "#,##0")
'End Sub
End Function
There's nothing heavier than an empty water bottle

User avatar
StuartR
Administrator
Posts: 12612
Joined: 16 Jan 2010, 15:49
Location: London, Europe

Re: Using FreeSpace as a randomizer or password generator

Post by StuartR »

I suspect memory allocation is not done to the nearest byte, so you would need to be careful which digits you chose from there too.
StuartR


User avatar
ChrisGreaves
PlutoniumLounger
Posts: 15635
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

Re: Using FreeSpace as a randomizer or password generator

Post by ChrisGreaves »

StuartR wrote:I suspect memory allocation is not done to the nearest byte, so you would need to be careful which digits you chose from there too.
Yes; I did about 20 runs and found that all the figures were multiples of 4,096.
I could divide by 4096, I suppose ...
From my point of view, time(milliseconds), disk and memory space are all grist for the mill.
There's nothing heavier than an empty water bottle