algorithm - A function where small changes in input always result in large changes in output -


I need an algorithm for a function that takes n integer and returns an integer. For small changes in the input, the resulting integer must be very different. Although I have taken many mathematical courses, I have not used that knowledge much and now I need some help ...

An important property of this function should be that if It is used as input, with a combination of coordinates and the result on an image (for example, as a grayscale value) is plotted, any repeating patterns can only be seen TE If the image is too large.

I have experimented with several algorithms with a small number of pseudo random numbers and in the end it killed me that the MD5 almost meets my criteria, except that it is not for numbers (less Less than I do not know). As a result, for some (like n = 2, it can easily be changed easily to get the list of integers) like the Python prototype:

  import helib DRF uniconum (X, Y): returns Intel (HSHLMMD5 (str (x) + ',' + str (wi)). HexDogest () [- 6:], 16)  

but obviously It seems incorrect to let stringings on when both input and output are integers, a good copy for this implementation Thapan what (pseudo-code, Python, or whatever language)?

Resolve a "hash" solution you are describing Absolutely

Any hash function that you use will be good; Hash functions can be determined on the basis of these criteria:

  • The degree to which they collision (two separate inputs producing the same output) - A sub-product is the degree of this in which the function reduces the output, which can never be accessed by any input.
  • Uniformity The set of inputs distributed equally to the distribution of their output
  • How small changes in degree inputs make big changes in output.
  • (see)

    Given how difficult it is to create a hash function which maximizes all these criteria, why not only use one of the most Already use the trusted and hash function now?

    It seems that changing the integer in the stars almost feels like the second layer of encryption! (Which is good for your purposes, I believe)

    However, your question is a hash function which asks the deal especially numbers , so we go here.


    Hash Functions That Work on Integer

    If you want to borrow an already existing algorithm, you

    There is a simple middle class method:

    • Take a number number
    • Square it
    • Cut off the digits and leave the middle digits Give the same length as your origin.

    that is,

      1111 => 01234321 = & gt; 2342  

    So, 1111 will be done in the middle class method by "hajay" 2342.

    In this way that is not effective, but for some palm, there is very little collision rates, a uniform distribution, and great anarchy-potential (small changes => major changes ) But if you have many values, then it's time to look for something ...

    All are probably the grand-father of all skilled and simple random numbers generators (mirasan twister) [actually, every Perhaps one implementation is probably out for the programming language .

    1. There is nothing wrong with string-based hash functions
    2. If you want to be with integers and want to become fancy , Then try to use your number for the pseudo-random number generator.

Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -