2 # -------------------------------------------------------------------------
3 # Copyright (c) 2015-2018 AT&T Intellectual Property
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
17 # -------------------------------------------------------------------------
20 from osdf.utils import cipherUtils
25 if len(sys.argv) != 4:
26 print("Invalid input - usage --> (options(encrypt/decrypt) input-value with-key)")
30 valid_option_values = ['encrypt', 'decrypt']
31 if enc_dec not in valid_option_values:
32 print("Invalid input - usage --> (options(encrypt/decrypt) input-value with-key)")
33 print("Option value can only be one of {}".format(valid_option_values))
34 print("You entered '{}'".format(enc_dec))
37 input_string = sys.argv[2]
38 with_key = sys.argv[3]
40 print("You've requested '{}' to be '{}ed' using key '{}'".format(input_string, enc_dec, with_key))
41 print("You can always perform the reverse operation (encrypt/decrypt) using the same key"
42 "to be certain you get the same results back'")
44 util = cipherUtils.AESCipher.get_instance(with_key)
45 if enc_dec.lower() == 'encrypt':
46 result = util.encrypt(input_string)
48 result = util.decrypt(input_string)
50 print("Your resultt: {}".format(result))