jodd-core/src/main/java/jodd/crypt/Threefish.java
public void init(final long[] key, final long[] tweak) {
		final int newNw = key.length;

		// only create new arrays if the value of N{w} changes (different key size)
		if (nw != newNw) {
			nw = newNw;

			switch (nw) {
				case WORDS_4:
					pi = PI4;
					rpi = RPI4;
					r = R4;
					break;
				case WORDS_8:
					pi = PI8;
					rpi = RPI8;
					r = R8;
					break;
				case WORDS_16:
					pi = PI16;
					rpi = RPI16;
					r = R16;
					break;
				default:
					throw new RuntimeException("Invalid threefish key");
			}

			this.k = new long[nw + 1];

			// instantiation of these fields here for performance reasons
			vd = new long[nw]; // v is the intermediate value v{d} at round d
			ed = new long[nw]; // ed is the value of e{d} at round d
			fd = new long[nw]; // fd is the value of f{d} at round d
			ksd = new long[nw]; // ksd is the value of k{s} at round d
		}

		System.arraycopy(key, 0, this.k, 0, key.length);

		long knw = EXTENDED_KEY_SCHEDULE_CONST;
		for (int i = 0; i < nw; i++) {
			knw ^= this.k[i];
		}
		this.k[nw] = knw;

		// set tweak values
		t[0] = tweak[0];
		t[1] = tweak[1];
		t[2] = t[0] ^ t[1];
	}
public void init(final long[] key, final long[] tweak) {
		final int newNw = key.length;

		// only create new arrays if the value of N{w} changes (different key size)
		if (nw != newNw) {
			nw = newNw;

			switch (nw) {
				case WORDS_4:
					pi = PI4;
					rpi = RPI4;
					r = R4;
					break;
				case WORDS_8:
					pi = PI8;
					rpi = RPI8;
					r = R8;
					break;
				case WORDS_16:
					pi = PI16;
					rpi = RPI16;
					r = R16;
					break;
				default:
					throw new RuntimeException("Invalid threefish key");
			}

			this.k = new long[nw + 1];

			// instantiation of these fields here for performance reasons
			vd = new long[nw]; // v is the intermediate value v{d} at round d
			ed = new long[nw]; // ed is the value of e{d} at round d
			fd = new long[nw]; // fd is the value of f{d} at round d
			ksd = new long[nw]; // ksd is the value of k{s} at round d
		}

		System.arraycopy(key, 0, this.k, 0, key.length);

		long knw = EXTENDED_KEY_SCHEDULE_CONST;
		for (int i = 0; i < nw; i++) {
			knw ^= this.k[i];
		}
		this.k[nw] = knw;

		// set tweak values
		t[0] = tweak[0];
		t[1] = tweak[1];
		t[2] = t[0] ^ t[1];
	}
public void init ( final long [ ] key , final long [ ] tweak ) { final int newNw = key . length ; // only create new arrays if the value of N{w} changes (different key size) if ( nw != newNw ) { nw = newNw ; switch ( nw ) { case WORDS_4 : pi = PI4 ; rpi = RPI4 ; r = R4 ; break ; case WORDS_8 : pi = PI8 ; rpi = RPI8 ; r = R8 ; break ; case WORDS_16 : pi = PI16 ; rpi = RPI16 ; r = R16 ; break ; default : throw new RuntimeException ( "Invalid threefish key" ) ; } this . k = new long [ nw + 1 ] ; // instantiation of these fields here for performance reasons vd = new long [ nw ] ; // v is the intermediate value v{d} at round d ed = new long [ nw ] ; // ed is the value of e{d} at round d fd = new long [ nw ] ; // fd is the value of f{d} at round d ksd = new long [ nw ] ; // ksd is the value of k{s} at round d } System . arraycopy ( key , 0 , this . k , 0 , key . length ) ; long knw = EXTENDED_KEY_SCHEDULE_CONST ; for ( int i = 0 ; i < nw ; i ++ ) { knw ^= this . k [ i ] ; } this . k [ nw ] = knw ; // set tweak values t [ 0 ] = tweak [ 0 ] ; t [ 1 ] = tweak [ 1 ] ; t [ 2 ] = t [ 0 ] ^ t [ 1 ] ; }
Initialize the cipher using the key and the tweak value.

@param key the Threefish key to use
@param tweak the tweak values to use
Initialize the cipher using the key and the tweak value .