How should I generate an initialization vector?

后端 未结 4 426
离开以前
离开以前 2020-12-28 08:50

I\'m sure there\'s not one answer to this question, but just trying to find out a general approach.

Using Java 1.4.2, I need to generate a key and IV for use in a sy

4条回答
  •  不思量自难忘°
    2020-12-28 09:13

    For some implementations, the SecureRandom class will help you out by producing true random numbers:

    Many SecureRandom implementations are in the form of a pseudo-random number generator (PRNG), which means they use a deterministic algorithm to produce a pseudo-random sequence from a true random seed. Other implementations may produce true random numbers, and yet others may use a combination of both techniques.

    It has two methods, getProvider() and getAlgorithm() which should give you some information about which implementation is used. From this page it seems that the pseudo random generator SHA1PRNG (which is seeded with true random data) is one of them or even the only one currently available.

提交回复
热议问题