Is UUID without dashes/hyphens valid?

The production in RFC 4122 (section 3, page 4), defines UUID string representation as UUID = time-low “-” time-mid “-” time-high-and-version “-” clock-seq-and-reserved clock-seq-low “-” node where each internal component is hex-encoded. Therefore, f47ac10b58cc4372a5670e02b2c3d479 is not a valid UUID representation.

What specific hash algorithm does MessageDigest.getInstance(“SHA”) return?

The JCE Specification lists standard names that an implementation is expected to support. “SHA-1” is specified, as are SHA-256, SHA-384, and SHA-512. “SHA”, “SHA-0″ and SHA-2” are not standard names and therefore may not be supported at all. You cannot guarantee what “SHA” will return, if anything at all, because it is not in the … 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

How to convert BigInteger to String in java

You want to use BigInteger.toByteArray() String msg = “Hello there!”; BigInteger bi = new BigInteger(msg.getBytes()); System.out.println(new String(bi.toByteArray())); // prints “Hello there!” The way I understand it is that you’re doing the following transformations: String —————–> byte[] ——————> BigInteger String.getBytes() BigInteger(byte[]) And you want the reverse: BigInteger ————————> byte[] ——————> String BigInteger.toByteArray() String(byte[]) Note that you … Read more

How to hash std::string?

For a quick solution involving no external libraries, you can use hash<std::string> to hash strings. It’s defined by including the header files hash_map or unordered_map (or some others too). #include <string> #include <unordered_map> hash<string> hasher; string s = “heyho”; size_t hash = hasher(s); If you decide you want the added security of SHA, you don’t … 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

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