A.7 Examples for Chapter 9

Example 22

Suppose you need to find a large random prime of 50 digits. Here is one way. The function NextPrime[x] finds the next prime greater than x. The function Random[Integer,{a,b}] gives a random integer between a and b. Combining these, we can find a prime:

In[1]:= NextPrime[Random[Integer, {10aˆ49, 10aˆ50 }]]

Out[1]= 73050570031667109175215303340488313456708913284291

If we repeat this procedure, we should get another prime:

In[2]:= NextPrime[Random[Integer, {10aˆ49, 10aˆ50 }]]

Out[2]= 97476407694931303255724326040586144145341054568331

Example 23

Suppose you want to change the text hellohowareyou to numbers:

In[3]:= txt2num1["hellohowareyou"]

Out[3]= 805121215081523011805251521

Note that we are now using ...

Get Introduction to Cryptography with Coding Theory, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.