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 2 years ago.
Improve this question
I haven't been able to find a solution to what may seem to be a simple problem.
Problem: sha512(9-e) = sha512(___)
Simply, is it possible to subtract the hash string of 'e' from the hash string of '9'? Not interested in the hash of "9-e" but an actual hash string resulting from the difference.
Additionally, is it possible to subtract letters from letters, and numbers from numbers?
ie: sha512(9-5) = sha512(4)
ie: sha512(c-a) = sha512(___)
Please correct me if I'm wrong. Am unable to find any documentation on the subject.
-Thanks
Concept: I want to achieve 99.99 in sha512. Having a encrypted hash key, I'm assuming the most used letter is e (Based on the English dictionary-ignoring other characters for now).
What I'm tying to solve: sha512(___) + sha512(e) = sha512(99.99).
The whole point of cryptographically secure hash functions is, that operations like the one you want to do are impossibly difficult to do. If what you want to do were possible, it would reduce the effective entropy of the hash and make finding a preimage collision attack much easier. It would be BAD if that were possible.
The thing closest to what you want to do, would fall into the realm of Homomorphic Encryption.
Related
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 2 years ago.
Improve this question
I'm watching a video on SQL and the guy is making a distinction between ' and ". In Python and R, I tend to use ' and " interchangeably while technically there is a minor difference or in certain situations one needs to be used. However for the most part in Python/R it doesn't matter.
Is this the same in SQL and the guy is just over analyzing or is there actually a big difference between ' and "? Unfortunately, I don't actually work with SQL so I can't really learn from experience - just have to watch vids.
Thanks
Yes, ' and " are very different in SQL.
' is used to indicate strings, such as 'Hello world!'; it is always required.
" is used to indicate identifiers, such as SELECT "name", "age" FROM "people"; it's optional when the name can't be confused with anything, but mandatory if you want unusual names (spaces, upper-case letters) or if you want a name that's reserved (such as "from"); for example SELECT "from", "to" FROM "time slots".
It's generally best to avoid names that have to be quoted, but the option is there if you need it. Many libraries that wrap SQL will habitually quote everything.
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
As a developer, a common mistake that I keep on repeating is assuming the data type of a column. I have read multiple articles regarding SQL column naming convention but have not seen any reference regarding data type as part of the column name - specifically for SQL Server.
E.g. Revenue_f for float, Organization_v for varchar, AccountNumber_i for integer and so on.
This must have been thought of already before but I want to know the reason why it is not being used, or an expert's input regarding the matter; pointing me to the right article/documentations will be greatly appreciated.
That is a horrible naming convention. Consider how awful it would be if you need to change AccountNumber to a character datatype. Do you then go back and rename the column and change every single query everywhere? Or do you leave the suffix in your column name even though it is no longer accurate? If you want to know the datatype of a column the ONLY way is to look at the definition of the table.
Also, a single character really is kind of useless. How do you handle nvarchar vs varchar? And what about the scale?
P.S. Even though I wrote an answer I am voting to close this question because it is primarily opinion based and as such is considered off topic for SO.
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 1 year ago.
Improve this question
I have a problem writing regular expression. I want to write a regular expression that replaces all double consonants with a single consonant.
Please help me to write such a rule in only one line.
Thanks in advance.
Here's a .NET regex that'll find any group of exactly two non-vowels:
[^aeiou]{2}
The following will work for groups longer than 2:
[^aeiou]{2,}
For example, this will match "llst" in "allstar."
Slightly uglier, but will match groups of 2 consonants, case-insensitive:
[QqWwRrTtYyPpSsDdFfGgHhJjKkLlZzXxCcVvBbNnMM]{2}
The following will match two identical non-vowels:
([^aeiou])\1
For example, this would match the "ll" in "all."
Once you have your regex, just use your chosen language's Regex.Replace function.
Since you did not specify the language, I'm going to go ahead and assume Javascript.
This should get you started:
console.log('babble bubble http htttp www'.replace(/([^aeiou\.,\/=?:\d&\s!##$%^*();\\|<>"'_+-])\1{1}/gi, "$1"));
See more here:
http://regexr.com/3ee47
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 7 years ago.
Improve this question
How acceptable is to name a variable like that:
int Δt = 3;
and not:
int timeDuration = 3;
I love the Delta character.... However it is only acceptable if this becomes a maintainable standard in your code, so that you or your team knows exactly what it is - and you never mix up notation.
It's likely to work, but I absolutely would not recommend it in anything other than personal projects.
Things like varying encoding languages (UTF etc) can affect these kind of unicode characters. Also the fact it's confusing to reliably type and not really hugely semantic.
Languages such as PHP have these guidelines for vars:
Variable names follow the same rules as other labels in PHP. A valid
variable name starts with a letter or underscore, followed by any
number of letters, numbers, or underscores. As a regular expression,
it would be expressed thus: '[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*'
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 7 years ago.
Improve this question
I need to complete cards numbers in sql. I have the prefix =11111 and the number of the card which is variable, therefore it could be '25' or '2130' but at the end I must have 14 numbers. So I need to fill spaces with zeros.
I've read about 'LPAD' but I don't understand very well this method.
You could use lpad, but if you're starting with a number you could use a 9-digit format model instead, and concatenate that onto your prefix:
select '11111' || to_char(25, 'FM000000000') from dual;
11111000000025
The FM format modifier stops Oracle adding a space for a potential +/- sign indicator.
SQL Fiddle demo
Use the ZEROFILL attribute.
But your database should only be responsible for saving data and not changing it before saving.
The best way would be to send the zerofilled data to the database server.