Obscure / encrypt an order number as another number: symmetrical, “random” appearance?

Pick a 8 or 9 digit number at random, say 839712541. Then, take your order number’s binary representation (for this example, I’m not using 2’s complement), pad it out to the same number of bits (30), reverse it, and xor the flipped order number and the magic number. For example: 1 = 000000000000000000000000000001 Flip = … Read more

Encrypting/Decrypting large files (.NET)

One organism’s large is another’s petite, though we all know expensive when we see it. Wink, wink. Try benchmarking something like the following in your environment and see where you’re at: EDIT 2/13/2012: The code has been updated as I’ve become (imperceptibly) smarter and also noticed a few cut’n’paste errors that had crept in. Mea … Read more

What’s the most secure possible Devise configuration?

Peppers: yes you are correct. There is not much additional security achieved with a pepper if you are using salt. Stretches: 12 is reasonable, however bcrypt only ensures a constant time. You should consider using the newer scrypt as it allows you to specify both a constant time and the amount of memory to use. … Read more

Practical applications of homomorphic encryption algorithms?

Here’s a wild shot in the dark: We’re thinking about protecting the plaintext from the person doing the computation on it. But what if the objective was to protect both the plaintext AND the algorithm? Take, for example, MRI machines. The most expensive part of the MRI machine is the algorithm in which the machine … Read more

PBEKeySpec what do the iterationCount and keyLength parameters influence?

The iteration count is the number of times that the password is hashed during the derivation of the symmetric key. The higher number, the more difficult it is to validate a password guess and then derive the correct key. It is used together with the salt which is used to prevent against attacks using rainbow … Read more

Encrypting credentials in a WPF application

Here’s a summary of my blog post: How to store a password on Windows? You can use the Data Protection API and its .NET implementation (ProtectedData) to encrypt the password. Here’s an example: public static string Protect(string str) { byte[] entropy = Encoding.ASCII.GetBytes(Assembly.GetExecutingAssembly().FullName); byte[] data = Encoding.ASCII.GetBytes(str); string protectedData = Convert.ToBase64String(ProtectedData.Protect(data, entropy, DataProtectionScope.CurrentUser)); return protectedData; … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)