Skip to content

Instantly share code, notes, and snippets.

@horitaku1124
Created May 22, 2014 04:35
Show Gist options
  • Save horitaku1124/d23c3f09a930dfcb4ce8 to your computer and use it in GitHub Desktop.
Save horitaku1124/d23c3f09a930dfcb4ce8 to your computer and use it in GitHub Desktop.
data = [7,13,17,24]
primes = [3,11]
pubkey1 = primes[0] * primes[1]
pubkey2 = (primes[0] - 1) * (primes[1] - 1)
key2 = 3
encd = data.map do |e|( e ** key2 )% pubkey1 end
p encd
secret = (pubkey2 + 1) / key2
data2 = encd.map do |e|( e ** secret ) % pubkey1 end
p data2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment