2,712 reputation
2819
bio website github.com/CodesInChaos
location Frankfurt, Germany
age
visits member for 4 years, 5 months
seen 4 hours ago

Nov
22
comment How deterministic are SessionIDs from SHA'd GUIDs?
As a non-secure PRNG this is fine. Hashing unique values produces random looking values. But it's not a secure PRNG, since GUIDs can be predictable. If your session IDs are secret tokens used to authenticate the client, this is not acceptable.
Nov
21
comment Initializing a variable as undefined
In javascript there is a difference between a missing property and a property that exists, but has the value undefined.
Nov
19
comment Why do so many websites prefer “git rebase” over “git merge”?
This is especially important in larger open source projects, where many people will read the logs and perhaps review the changes. Nobody wants to see a contributor's dozens of merges and incomplete intermediate version that combine into on logically consistent change.
Nov
16
comment Shuffling algorithm with no “self-mapping”?
@RobertHarvey In this context "unbiased" means that all allowed configurations are equally likely. Generating a random permutation and rejecting forbidden values produces such an unbiased configuration. For many problems this approach is prohibitively expensive, but in this case it is pretty fast.
Nov
16
comment Shuffling algorithm with no “self-mapping”?
@OregonTrail As Derek said, on average it's only 2.7 times as expensive as Fisher-Yates, even without early-out. With early out, the overhead (approximately) halves, so it's only ~1.8 times as expensive. That's pretty efficient IMO.
Nov
15
comment Why does the modifier access for the properties need to be public with Unity?
@Telastyn 1) Manual DI should be possible as well. An IoC container is just a convenience. Preferably the your class doesn't even know there is such thing as IoC containers or even worse which one you're using. 2) The IoC container is external to the object, so it should go through the public API. Either calling a public constructor, or setting a public property.
Nov
14
comment Generating a Nakagami Random Variable
In the worst case one can always use an approximation of the inverse CDF combining it with a rejection function to arrive at the precise distribution.
Nov
13
comment Signing redistributed files
Depends on the license of the library you're using.
Nov
13
comment How to model an address type in DDD?
Certainly seems like the cleanest solution, but since addresses are typically used only once, denormalizing them into the user-address connection is probably the most practical approach in many situations.
Nov
13
comment So Singletons are bad, then what?
There is one more condition to be the bad singleton pattern: Mutability or access to external mutable state. For example making something like AsciiEncoding a singleton with a static accessor would be fine since any possible instance of it would be equivalent.
Nov
13
comment Updating password hashing without forcing a new password for existing users
if H1 is really terrible this won't be secure. Being terrible in this context is mostly about losing a lot of entropy from the input. Even MD4 and MD5 are nearly perfect in this regard, so this approach is only insecure for some homebrew hashes or hashes with really short output (below 80 bits).
Nov
13
comment Why not expose a primary key
hm? Obviously it requires SSL, but that's the case no matter how you authenticate and authorize. Over SSL an attacker can't learn the token (just like they can't learn cookies) and it also prevents replay attacks. The main downside of this approach is that you can't revoke access for individual users, so I prefer using it only for immutable resources. Revoking access to immutable resources is meaningless since an attacker could simply store a local copy.
Nov
13
comment Why not expose a primary key
Unguessable urls (e.g. containing a cryptographically random 128 bit token) are one form of proper authorization.
Nov
12
comment What is the advantage to using a factor of 1024 instead of 1000 for disk size units?
In some low level corners binary units are useful (for example disk sector size, RAM pages etc.). But for high level values directed at end users, like disk or file sizes, there is little reason to use binary prefixes.
Nov
10
comment Updating password hashing without forcing a new password for existing users
Password hashing has barely evolved over the last 15 years. Bcrypt has been published in 1999 and is still of of the recommended hashes. Only one significant improvement has happened since then: sequentially memory hard hashes, pioneered by scrypt.
Nov
10
comment Updating password hashing without forcing a new password for existing users
The problem with this technique is that for accounts don't log in, you can't update the hashes. In my experience most users won't login for years if ever (unless you delete inactive users). Your abstraction doesn't really work either, since it doesn't account for salts. The standard abstraction is having two functions, one for verification and one for creation.
Nov
4
comment Is it reasonable to null guard every single dereferenced pointer?
I'd throw at points where invalid input can be passed in through a public API (in this case in the constructor) and assert for internal consistency checks (I know it'll never be null because I already checked in the constructor).
Nov
4
comment Since Garbage Collection is non-deterministic, why isn't it used for secure random number generation?
@Schilcote Even without specialized RNG instructions (Intel's RDRAND and RDSEED) a computer isn't completely deterministic. Some timings aren't completely specified and can depend on external factors like temperature.
Nov
1
comment Dependency injection: At what point am I allowed to create a new object?
I recommend IoC for services and policies. For model or helper classes I'd simply use new. Of course there are a few entry points where you need to call into the IoC container, but there shouldn't be many. Typically you configure the IoC once and then ask for one class to be resolved per request. In the case of MVC that's typically the controller.
Oct
25
comment Regarding little endian and big endian conversion
Usually you don't need to convert endinaness of integers, you need to read them from the byte sequence using the desired endianness.