Skip to content

Hack to force string-comparisons to be done case-sensitivily. #1

@Alxandr

Description

@Alxandr

I've read (parts of) your code, and I noticed the commend about case-sensetive checking only beeing to set in the db, however, I though I'd show you this little technique I use to achive the same with minimal overhead:

        CryptoKey ICryptoKeyStore.GetKey(string bucket, string handle)
        {
            // It is critical that this lookup be case-sensitive, which can only be configured at the database.
            var _db = SymetricCryptoKeys.Where(k => k.Bucket == bucket && k.Handle == handle).ToList();
            var matches = from key in _db // hack to make case-sensitive
                          where key.Bucket == bucket && key.Handle == handle
                          select new CryptoKey(key.Secret, key.ExpiresUtc.AsUtc());
            return matches.FirstOrDefault();
        }

Notice that the last itteration is done on in-memory objects, thus the comparison is done in C#, not in the db.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions