示例#1
0
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and limitations under the License
'''

# Dependencies
import ElGamal as eg
import Redis
import ast

RCh = Redis.RedisChannel()
print("Alice creates her ElGamal Keys: ")
AliceElGamal = eg.ElGamalEncryption(False, keyFile='Utils/primes50.txt')
print("Alice connects and reads Bob's Public key from the channel:")
RCh.connect()
BobPubKey = ast.literal_eval(
    RCh.getRedisVariable('BobPublicKey').decode('utf-8'))
print('Bob Key is: ' + str(BobPubKey))
plainText = 'ciao!'
print('Plain Text: ' + str(plainText))
print('Alice encrypts her message:')
encrypted = AliceElGamal.encrypt(data=plainText, receiverPubKey=BobPubKey)
print(encrypted)
print('Alice sends her message.')
RCh.redisPublish(str(encrypted))