Add salt to pycrypto KDF - useful? [closed] - pycrypto

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I have noted some sources indicate that when using a KDF like PBKDF2 some advocate injecting the salt at the time of execution - like this:
dv = salt + PBKDF2(salt + password, salt)
Versus the "plain" usage of
dv = PBKDF2(password, salt)
When using the PyCrypto.Protocol.KDF PBKDF2 function (linked above), do the extra salt parameters add any benefit if no two passwords will have the same salt (but the salt will be stored with the password)?
Presumably the risk is having an oracle whereby identical passwords would be revealed as-such, encoded. Is this the case or is there another concern one ought to be mindful of?
If this is the only concern I would expect, in the absence of a fault in the algorithms that permits short-circuiting, a plainly used salt obliges one to recheck every password the entire number of iterations. Is this the case?

Related

Why do we check if empty before we move? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 4 years ago.
Improve this question
I see a lot of codes like this:
if WA > SPACES
move WA to WA2
end-if
What are the advantages that this is checked? Is it more efficient to check if it is empty than to just move it anyways?
Additional information:
WA and WA2 can be simple structures (without fillers) but also just simple attributes. They are not redifined and typed as chars or structures of chars. They can be either low-values (semantically NULL) or have alphanumeric content.
Nobody can tell you what the actual reason is except for the people who coded it, but here is a very probable reason:
Usually this is accompanied with an ELSE that would cover what happens if the value is less than spaces, but in this case I would assume that what every happens to this data later is relying on that field NOT being LOW-VALUES or some funky non-displayable control character.
If I had to guess, I would assume that WA2 is initialized to spaces. So doing this check before the move ensures that nothing lower than spaces would be moved to that variable. Remember, less than spaces does not mean empty, it just means that hex values of that string are less than X'40' (so for example is the string was full of low values, it would be all X'00'. So I would guess that its more about ensuring that the data is valid than efficiency.

Lua Script to insert 100000 random keys on redis [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I need to test this on some redis instances.
Is there a way to do it?
for i = 1, 100000, 1 do
redis.call("SET", "ZzZ_MYKEY_ZzZ_"..i.."key", i)
end
return "Ok!"
Save this as redis_load.luaand execute with redis-cli --eval redis_load.lua
Redis' Lua scripts (try to) prevent you from doing random writes, the reason being that it would break replication. While arguably there ways to work around that restriction, you really shouldn't :) Instead of try to Lua your way, consider using redis-benchmark (or memtier-benchmark) to populate your database with random values.
That said, if this is a once off, you could generate the keys with Lua. Further more, with v3.2's new effect-based replication you can even do really random stuff.

Encrypting file names [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I need an encryption method that will encrypt (not encode) a file name so that the resulting encrypted string can be stored in a SQLite table.
The encryption method must not insert #0 characters into the resulting TString (non ANSI).
Example:
Before: hello_world.txt
After: y381a82jzseoi1
The length of the two strings needs to be the same, or at least not more than 10-15% longer in length.
Any suggestions?
I would do it like this:
Convert from text to binary using TEncoding.GetBytes. You'll need to decide on an encoding. To support Unicode UTF-8 or UTF-16 would be the most likely choices. Often UTF-8 is the most efficient in terms of space.
Encrypt using your chosen encryption algorithm. This converts the binary data returned by TEncoding.GetBytes into encrypted binary data.
Save the encrypted binary data to the database as a blob.
Note that I have avoided converting the encrypted binary data back to text. This deals with your desire to avoid null-terminators by simply side-stepping the issue. The key point for you to recognise is that encryption operates on binary data rather than text. It is an exceptionally common misconception that encryption algorithms operate on text.
If, for some reason that I do not anticipate, you simply must store the data as text, then you should encode it from binary to text. You could implement base255 encoding to avoid having null terminators, and keep the size down.

How to insert charactor like "don't" in Sqlite in ios [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 9 years ago.
Improve this question
I am inserting some keyword like Don't , has'nt in Sqlite which is not inserted.any one have idea about it.
Use ' as escape character and insert it like this:
dont''t
Documentation:
A single quote within the string can be encoded by putting two single quotes in a row - as in Pascal
In case you are using an API to connect with Sqlite, instead of manipulating the original string a better approach would be to use sqlite3_bind_text() function to bind a value to a ? placeholder in the SQL. Thanks to #Rob for pointing this out.

NSString's hash method and back? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
Once I use [NSString hash] and get a NSUInteger, is there any way I can use that NSUInteger and turn it back into the original NSString? Apple doesn't really say anything about the implementation of the hash method in the docs.
FYI: I'm trying to store identifierForVendor as a NSNumber (specifically in either the major or minor property of a CLBeacon).
No. The hash is 32 or 64 bits, a string can be much longer, so it is inherently lossy, and the hash values are not unique (the same hash corresponds to multiple strings).
Actually, hash is not supposed to be de-coded. You may want to read something like http://en.wikipedia.org/wiki/Hash_function
Apple says "If two string objects are equal (as determined by the isEqualToString: method), they must have the same hash value". That's all you can get.
If you want to store it for later comparisons, then you should hash the both NSStrings & compare the resulting NSUIntegers

Resources