Comments (3)
Hi; in debugging it seems it is already disposed when the script's source stack is finished, I will contribute said fix regardless.
As for the latter, I personally don't find it any more understandable for me, but to be fair that is a fairly subjective one.
Thank you for helping out!
from antirip.
I'll gladly explain the second part. The RNGCryptoServiceProvider is purpose-made for generating cryptographically secure randomness which is used for things like secret keys, salts etc. The code example is definitely not as readable as it could be with some comments. It does the following:
- Create an array of four bytes
- Pass the array to RNGCryptoServiceProvider to fill it with random bytes
- Loop over every bit inside the array of random bytes and fill the _bitArray with them
That last step is done by sliding a bitmask over the every byte and checking if a specific bit is 0 (false) or 1 (true).
- (1 << j): create bitmask where one bit is 1 and all the rest is 0
- randomBytes[i] & (1 << j): apply bitmask to one of the random bytes
- (randomBytes[i] & (1 << j)) != 0: if it's anything but 0 (the bitmask and random byte shared a 1 bit in the same position) it's true
step: 1 2 3 4
random: 01000101 01000101 01000101 01000101
mask: 00000001 00000010 00000100 00001000
result: 00000001 00000000 00000100 00000000
boolean: true false true false
Looking at it, it may be clearer to write this:
public void GenerateNewKey()
{
using (var rng = new RNGCryptoServiceProvider())
{
byte[] randomBytes = new byte[4];
rng.GetBytes(randomBytes);
int randomNumber = BitConverter.ToInt32(randomBytes);
for (int i = 0; i < 32; i++)
{
_bitKeys[i] = ((randomNumber & (1 << i)) != 0);
}
}
}
from antirip.
Like said before though, this does fall into subjectivity. To me, this makes it more vague, as I find standardized math; even if longer, easier to read than bitshifting. The only type of people who understand bitshifting already would not have issues with the looping alternative. Due to such, this part is wontfix, as it is too subjective overall to take either side objectively, so it falls to my subjective status.
Thank you though.
from antirip.
Related Issues (8)
- Why is this not a Fork? HOT 2
- Would it be possible to write the encryption key over osc instead of htrough unity? HOT 2
- Poiyomi shaders don't like Water HOT 1
- Fallback system HOT 3
- Add a mappings from non-obfuscated to obfuscated names HOT 8
- Only actively equipped materials are properly encrypted HOT 1
- Suggestion: Experimentation with using Normal values for Public Key HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from antirip.