-
Notifications
You must be signed in to change notification settings - Fork 0
SaveIntegrityUtility (en)
This is a static class that provides the methods to shuffle and unshuffle bytes, and it can generates a SHA-256 hash.
- originalBytes: Bytes list to shuffle.
- seed: Seed to be used in the random number generator.
This method shuffle bytes in this way: It generates a shuffle order by GetOrder() method, returning a shuffled number list, then a for loop is created according to the bytes list length getting each byte position that was generated by shuffled numbers list and adding the bytes in an array. Then, returning a shuffled bytes list.
Example: We have the following text that would be our bytes: ABCDE and our generated order was: 3 2 0 1 4
The original position is:
A B C D E
0 1 2 3 4
Moving to another array in a shuffled way:
D C A B E
3 2 0 1 4
- shuffledBytes: Bytes list to unshuffle.
- seed: Seed used in the random number generator.
This method unshuffles the bytes according to the seed used in the shuffling. If another seed is used, the unshuffling will return the wrong order.
- content: Content to generate a hash.
- salt: "Salt" to add in the content.
This method returns a hash of the content with a "salt", making the hash more unique and difficulting a hash injection.
- bytesSize: List bytes size.
- seed: Seed to be used in the random number generator.
This methods starts generating a possible numbers list based in the bytes amount, then it moves the generated position to a new numbers list through a while loop.