I would like to create a finite state machine that my users cannot see, but can import as a module; or possibly as an encrypted text file to be decrypted and eval(); or ??? I'm open to suggestion as I'm really unsure how to proceed.
- It must be able to handle NumPy arrays.
- The remainder of the script must be open source to the user.
- Use of the machine would eventually expire.
The state machine must remain NATURAL INTELLECTUAL PROPERTY; 100% secure hidden.
How would I go about this? Here is a sample of what I'm looking to do:
import random
import time
import numpy as np
def state_machine(a,b,c):
# This machine should be hidden from users
expiration = 1500000000
if time.time() < expiration:
state = 0
if a[-1]>b[-1]<c[-1]:
state = 1
elif a[-1]<b[-1]<c[-1]:
state = -1
return state
else:
return 'subscription expired'
def generate_3_random():
# Generate some random data for testing purposes
a = np.random.random(2)
b = np.random.random(2)
c = np.random.random(2)
return a,b,c
a,b,c = generate_3_random()
print [a,b,c]
state = state_machine(a,b,c)
print state
Sample output
>>>[array([ 0.320481 , 0.83016095]), array([ 0.15776184, 0.35658263]), array([ 0.96922252, 0.78727468])]
3
Taking a module path, the user version would then look like this:
import my_encrypted_machine
import random
import time
import numpy as np
def generate_3_random():
# Generate some random data for testing purposes
a = np.random.random(2)
b = np.random.random(2)
c = np.random.random(2)
return a,b,c
a,b,c = generate_3_random()
print [a,b,c]
state = my_encrypted_machine.state_machine(a,b,c)
print state
Output would then be in the same format as the non protected version above.