( input, nRounds=20, checkRounds=True )
return little16_i32.pack( *x )
Do nRounds Salsa20 rounds on a copy of 
            input: list or tuple of 16 ints treated as little-endian unsigneds.
        Returns a 64-byte string.
Do nRounds Salsa20 rounds on a copy of 
            input: list or tuple of 16 ints treated as little-endian unsigneds.
        Returns a 64-byte string.
Do nRounds Salsa20 rounds on a copy of input : list or tuple of 16 ints treated as little - endian unsigneds . Returns a 64 - byte string .
def salsa20_wordtobyte( input, nRounds=20, checkRounds=True ):
    """ Do nRounds Salsa20 rounds on a copy of 
            input: list or tuple of 16 ints treated as little-endian unsigneds.
        Returns a 64-byte string.
        """

    assert( type(input) in ( list, tuple )  and  len(input) == 16 )
    assert( not(checkRounds) or ( nRounds in [ 8, 12, 20 ] ) )

    x = list( input )

    def XOR( a, b ):  return a ^ b
    ROTATE = rot32
    PLUS   = add32

    for i in range( nRounds // 2 ):
        # These ...XOR...ROTATE...PLUS... lines are from ecrypt-linux.c
        # unchanged except for indents and the blank line between rounds:
        x[ 4] = XOR(x[ 4],ROTATE(PLUS(x[ 0],x[12]), 7));
        x[ 8] = XOR(x[ 8],ROTATE(PLUS(x[ 4],x[ 0]), 9));
        x[12] = XOR(x[12],ROTATE(PLUS(x[ 8],x[ 4]),13));
        x[ 0] = XOR(x[ 0],ROTATE(PLUS(x[12],x[ 8]),18));
        x[ 9] = XOR(x[ 9],ROTATE(PLUS(x[ 5],x[ 1]), 7));
        x[13] = XOR(x[13],ROTATE(PLUS(x[ 9],x[ 5]), 9));
        x[ 1] = XOR(x[ 1],ROTATE(PLUS(x[13],x[ 9]),13));
        x[ 5] = XOR(x[ 5],ROTATE(PLUS(x[ 1],x[13]),18));
        x[14] = XOR(x[14],ROTATE(PLUS(x[10],x[ 6]), 7));
        x[ 2] = XOR(x[ 2],ROTATE(PLUS(x[14],x[10]), 9));
        x[ 6] = XOR(x[ 6],ROTATE(PLUS(x[ 2],x[14]),13));
        x[10] = XOR(x[10],ROTATE(PLUS(x[ 6],x[ 2]),18));
        x[ 3] = XOR(x[ 3],ROTATE(PLUS(x[15],x[11]), 7));
        x[ 7] = XOR(x[ 7],ROTATE(PLUS(x[ 3],x[15]), 9));
        x[11] = XOR(x[11],ROTATE(PLUS(x[ 7],x[ 3]),13));
        x[15] = XOR(x[15],ROTATE(PLUS(x[11],x[ 7]),18));

        x[ 1] = XOR(x[ 1],ROTATE(PLUS(x[ 0],x[ 3]), 7));
        x[ 2] = XOR(x[ 2],ROTATE(PLUS(x[ 1],x[ 0]), 9));
        x[ 3] = XOR(x[ 3],ROTATE(PLUS(x[ 2],x[ 1]),13));
        x[ 0] = XOR(x[ 0],ROTATE(PLUS(x[ 3],x[ 2]),18));
        x[ 6] = XOR(x[ 6],ROTATE(PLUS(x[ 5],x[ 4]), 7));
        x[ 7] = XOR(x[ 7],ROTATE(PLUS(x[ 6],x[ 5]), 9));
        x[ 4] = XOR(x[ 4],ROTATE(PLUS(x[ 7],x[ 6]),13));
        x[ 5] = XOR(x[ 5],ROTATE(PLUS(x[ 4],x[ 7]),18));
        x[11] = XOR(x[11],ROTATE(PLUS(x[10],x[ 9]), 7));
        x[ 8] = XOR(x[ 8],ROTATE(PLUS(x[11],x[10]), 9));
        x[ 9] = XOR(x[ 9],ROTATE(PLUS(x[ 8],x[11]),13));
        x[10] = XOR(x[10],ROTATE(PLUS(x[ 9],x[ 8]),18));
        x[12] = XOR(x[12],ROTATE(PLUS(x[15],x[14]), 7));
        x[13] = XOR(x[13],ROTATE(PLUS(x[12],x[15]), 9));
        x[14] = XOR(x[14],ROTATE(PLUS(x[13],x[12]),13));
        x[15] = XOR(x[15],ROTATE(PLUS(x[14],x[13]),18));

    for i in range( len( input ) ):
        x[i] = PLUS( x[i], input[i] )
    return little16_i32.pack( *x )
def salsa20_wordtobyte ( input , nRounds = 20 , checkRounds = True ) : assert ( type ( input ) in ( list , tuple ) and len ( input ) == 16 ) assert ( not ( checkRounds ) or ( nRounds in [ 8 , 12 , 20 ] ) ) x = list ( input ) def XOR ( a , b ) : return a ^ b ROTATE = rot32 PLUS = add32 for i in range ( nRounds // 2 ) : # These ...XOR...ROTATE...PLUS... lines are from ecrypt-linux.c # unchanged except for indents and the blank line between rounds: x [ 4 ] = XOR ( x [ 4 ] , ROTATE ( PLUS ( x [ 0 ] , x [ 12 ] ) , 7 ) ) x [ 8 ] = XOR ( x [ 8 ] , ROTATE ( PLUS ( x [ 4 ] , x [ 0 ] ) , 9 ) ) x [ 12 ] = XOR ( x [ 12 ] , ROTATE ( PLUS ( x [ 8 ] , x [ 4 ] ) , 13 ) ) x [ 0 ] = XOR ( x [ 0 ] , ROTATE ( PLUS ( x [ 12 ] , x [ 8 ] ) , 18 ) ) x [ 9 ] = XOR ( x [ 9 ] , ROTATE ( PLUS ( x [ 5 ] , x [ 1 ] ) , 7 ) ) x [ 13 ] = XOR ( x [ 13 ] , ROTATE ( PLUS ( x [ 9 ] , x [ 5 ] ) , 9 ) ) x [ 1 ] = XOR ( x [ 1 ] , ROTATE ( PLUS ( x [ 13 ] , x [ 9 ] ) , 13 ) ) x [ 5 ] = XOR ( x [ 5 ] , ROTATE ( PLUS ( x [ 1 ] , x [ 13 ] ) , 18 ) ) x [ 14 ] = XOR ( x [ 14 ] , ROTATE ( PLUS ( x [ 10 ] , x [ 6 ] ) , 7 ) ) x [ 2 ] = XOR ( x [ 2 ] , ROTATE ( PLUS ( x [ 14 ] , x [ 10 ] ) , 9 ) ) x [ 6 ] = XOR ( x [ 6 ] , ROTATE ( PLUS ( x [ 2 ] , x [ 14 ] ) , 13 ) ) x [ 10 ] = XOR ( x [ 10 ] , ROTATE ( PLUS ( x [ 6 ] , x [ 2 ] ) , 18 ) ) x [ 3 ] = XOR ( x [ 3 ] , ROTATE ( PLUS ( x [ 15 ] , x [ 11 ] ) , 7 ) ) x [ 7 ] = XOR ( x [ 7 ] , ROTATE ( PLUS ( x [ 3 ] , x [ 15 ] ) , 9 ) ) x [ 11 ] = XOR ( x [ 11 ] , ROTATE ( PLUS ( x [ 7 ] , x [ 3 ] ) , 13 ) ) x [ 15 ] = XOR ( x [ 15 ] , ROTATE ( PLUS ( x [ 11 ] , x [ 7 ] ) , 18 ) ) x [ 1 ] = XOR ( x [ 1 ] , ROTATE ( PLUS ( x [ 0 ] , x [ 3 ] ) , 7 ) ) x [ 2 ] = XOR ( x [ 2 ] , ROTATE ( PLUS ( x [ 1 ] , x [ 0 ] ) , 9 ) ) x [ 3 ] = XOR ( x [ 3 ] , ROTATE ( PLUS ( x [ 2 ] , x [ 1 ] ) , 13 ) ) x [ 0 ] = XOR ( x [ 0 ] , ROTATE ( PLUS ( x [ 3 ] , x [ 2 ] ) , 18 ) ) x [ 6 ] = XOR ( x [ 6 ] , ROTATE ( PLUS ( x [ 5 ] , x [ 4 ] ) , 7 ) ) x [ 7 ] = XOR ( x [ 7 ] , ROTATE ( PLUS ( x [ 6 ] , x [ 5 ] ) , 9 ) ) x [ 4 ] = XOR ( x [ 4 ] , ROTATE ( PLUS ( x [ 7 ] , x [ 6 ] ) , 13 ) ) x [ 5 ] = XOR ( x [ 5 ] , ROTATE ( PLUS ( x [ 4 ] , x [ 7 ] ) , 18 ) ) x [ 11 ] = XOR ( x [ 11 ] , ROTATE ( PLUS ( x [ 10 ] , x [ 9 ] ) , 7 ) ) x [ 8 ] = XOR ( x [ 8 ] , ROTATE ( PLUS ( x [ 11 ] , x [ 10 ] ) , 9 ) ) x [ 9 ] = XOR ( x [ 9 ] , ROTATE ( PLUS ( x [ 8 ] , x [ 11 ] ) , 13 ) ) x [ 10 ] = XOR ( x [ 10 ] , ROTATE ( PLUS ( x [ 9 ] , x [ 8 ] ) , 18 ) ) x [ 12 ] = XOR ( x [ 12 ] , ROTATE ( PLUS ( x [ 15 ] , x [ 14 ] ) , 7 ) ) x [ 13 ] = XOR ( x [ 13 ] , ROTATE ( PLUS ( x [ 12 ] , x [ 15 ] ) , 9 ) ) x [ 14 ] = XOR ( x [ 14 ] , ROTATE ( PLUS ( x [ 13 ] , x [ 12 ] ) , 13 ) ) x [ 15 ] = XOR ( x [ 15 ] , ROTATE ( PLUS ( x [ 14 ] , x [ 13 ] ) , 18 ) ) for i in range ( len ( input ) ) : x [ i ] = PLUS ( x [ i ] , input [ i ] ) return little16_i32 . pack ( * x )