implemented createKeyStream