public String encode(String plain)
	 {
		//int period=key.length();
		String plain_u=plain.toUpperCase();
		int left=plain_u.length()%(key.length()*2);
		int add_x=0;
        if(left!=0)
        {
        	add_x=key.length()*2-left;
        }
        for(int i=0;i<add_x;i++)
        {
        	plain_u+='X';
        }
		char[][] block=Incomp_column.build_block(plain_u, -1,key.length(), 0);
		char[][] result_block=new char[block.length][block[0].length];
		for(int i=0;i<block[0].length;i++)
		{
			//encipher by column
			for(int j=0;j<block.length;j+=2)
			{
				Pair<Character> p=get_ct(block[j][i],block[j+1][i],key.charAt(i)); 
				result_block[j][i]=p.get_first();
				result_block[j+1][i]=p.get_second();
			}
		}
		//Random r=new Random();
		//int key_len=1+r.nextInt(7);
		String r=read_block(result_block, true);
		return r;
	 }