Method 2 will never get you a prime number larger than 16, such as 17.
Method 1 is easy if you use a source that uses the binary numbering, also known (according to Wikipedia) as the Fu Xi or Shao Yong ordering. Roll your 1d6 for even-odd. Let a 1, 3, or 5 represent an unbroken line, and a 2, 4, or 6 a broken line. Represent an unbroken line by a 1 and a broken line by a 0, so that a hexagram can be described by 6 bits: 010001, for instance.
On this
wikibooks site for the I Ching, you can look up hexagrams by searching for this 6-digit code. The page numbers the lines from the top down. For instance, 010001 gives you trigram 3 of the King Wen sequence, Zhun, Beginning.