271 But it should be much better than what is commonly used in older |
271 But it should be much better than what is commonly used in older |
272 programs (current time) or even a constant." |
272 programs (current time) or even a constant." |
273 |
273 |
274 |hash| |
274 |hash| |
275 |
275 |
276 hash := MD5Stream new. |
|
277 |
|
278 RandomSalt isNil ifTrue:[ |
276 RandomSalt isNil ifTrue:[ |
279 RandomSalt := 1. |
277 RandomSalt := 1. |
280 ] ifFalse:[ |
278 ] ifFalse:[ |
281 RandomSalt := RandomSalt + 1. |
279 RandomSalt := RandomSalt + 1. |
282 ]. |
280 ]. |
283 hash nextPut:RandomSalt. |
281 |
284 hash nextPutAll:Time microsecondClockValue asLargeInteger digitBytes. |
282 hash := MD5Stream new. |
285 hash nextPutAll:OperatingSystem getProcessId asLargeInteger digitBytes. |
283 hash |
286 hash nextPutAll:(ObjectMemory addressOf:(Object new)) asLargeInteger digitBytes. |
284 nextPut:RandomSalt; |
287 hash nextPutAll:(ObjectMemory oldSpaceUsed) asLargeInteger digitBytes. |
285 nextPut:Time microsecondClockValue; |
288 hash nextPutAll:(ObjectMemory newSpaceUsed) asLargeInteger digitBytes. |
286 nextPut:OperatingSystem getProcessId; |
|
287 nextPut:(ObjectMemory addressOf:Object new); |
|
288 nextPut:ObjectMemory oldSpaceUsed; |
|
289 nextPut:ObjectMemory newSpaceUsed. |
289 [ |
290 [ |
290 hash nextPutAll:(OperatingSystem getCPUCycleCount) asLargeInteger digitBytes. |
291 hash nextPut:OperatingSystem getCPUCycleCount. |
291 ] on:PrimitiveFailure do:[]. |
292 ] on:PrimitiveFailure do:[]. |
292 |
293 |
293 "/ any other cheap sources of entropy? |
294 "/ any other cheap sources of entropy? |
294 |
295 |
295 "/ I think there is no problem in that MD5 is not a secure hash algo here - the idea is to shuffle the bits around a bit |
296 "/ I think there is no problem in that MD5 is not a secure hash algo here - the idea is to shuffle the bits around a bit |