sobota, 19 marca 2016

Shrinker pseudo-random key generator

Shrinker generator based on LFSR implemented in other posts.

This generator is very fast. Generated bits seems to have a good cryptographic properties. String LFSR 1 is moved each time. The purpose of the function f is to shift register LFSR 2 in the case where one out of LFSR 1 or lower transfer operation, when the voltage on LFSR 1 is 0.
int shrinker() {
    int lf1 = lfsr_1();
    int lf2 = lfsr_2();

    while (lf1 != 1) {
        lf1 = lfsr_1();
        lf2 = lfsr_2();
    return lf2;
Source code:

czwartek, 10 marca 2016

swagger-maven-plugin with Spring MVC annotations sample

I have found that adding swagger documentation for "legacy" spring application is not that easy :D

After a lot of research, I decided to use swagger-maven-plugin
but I had a problem, JSON is generated but without any API detected. Searching around the net I realized that im not the only one.

Finally I got the working example. Check this out:

sobota, 5 marca 2016

Stop and go

Stop and go generator based on LFSR implemented in other posts.

It has been proposed by CG Gunther in 1987. As the Geffe algorithm, was built with three LFSR's. It is based on the timing clock. LFSR 1 is moved at each clock cycle and controls the other two registers. If the output value will be 1 to 2 of the register LFSR is advanced in the register LFSR and the three preceding bit is repeated. However, if the output of LFSR 1 is 0, the LFSR 3 is moved and the previous bit in LFSR 2 is repeated. The output bits of the LFSR registers LFSR 2 and 3 are added modulo 2 to generate another pseudo-random bit sequence. If the length of all three registers are relatively prime , and periods of LFSR generators LFSR 2 and 3 have the greatest common divisor equal to 1 , the period of the generator is equal to the product of the periods of all registers.

So here's the code :)

int stop_and_go() {
    int lf2, lf3;
    if (lfsr_1() == 1) {
        lf2 = lfsr_2();
        lf3 = reg3[0];
    else {
        lf3 = lfsr_3();
        lf2 = reg2[0];
    return lf2 ^ lf3;
Source code:

wtorek, 1 marca 2016

Geffe pseudo-random key generator

Geffe generator based on LFSR implemented in other posts.

The algorithm was designed in 1973 . By P.R. Geffe. It is based on interconnected nonlinear three registers LFSR. This generator is also cryptographically weak. It turns out that the sequence of the output is 75 % of the time equal to the output string LFSR 1 and 25 % of the time string to the output LFSR. Such a correlation is very dangerous and can easily be broken. Geffe generator can be expanded in such a way that in place of the generator LFSR 1 , LFSR 2 , LFSR 3 will be inserted three generators of Geffe. The resulting generator is characterized by a high modulus of complexity.

int geffe() {
    int lf1 = lfsr_1();
    int lf2 = lfsr_2();
    int lf3 = lfsr_3();
    int and1 = lf1 & lf2;
    int and2;
    if (lf2 == 1) and2 = 0 & lf3;
    else and2 = 1 & lf3;
    return and1 ^ and2;
Source code: