increasing test coverage to 20 percent
[aai/sparky-fe.git] / src / utils / Crypto.js
index 7f9408e..91b6799 100644 (file)
@@ -2,8 +2,8 @@
  * ============LICENSE_START=======================================================
  * org.onap.aai
  * ================================================================================
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017 Amdocs
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017-2018 Amdocs
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  * ============LICENSE_END=========================================================
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
  */
 /**
  * Created by salmaat on 7/13/2017.
  */
 import CryptoJS from 'crypto-js';
 
-var key = 'key2017';
+const key = 'key2017';
 
 function encrypt(text) {
   var encrypted = CryptoJS.AES.encrypt(text, key);
@@ -37,8 +35,17 @@ function decrypt(text) {
   return decrypted.toString(CryptoJS.enc.Utf8);
 }
 
+function encode(phrase) {
+  return CryptoJS.enc.Utf16.parse(phrase);
+}
+
+function decode(encodedPhrase) {
+  return CryptoJS.enc.Utf16.stringify(encodedPhrase);
+}
 
 module.exports = {
   encrypt: encrypt,
-  decrypt: decrypt
+  decrypt: decrypt,
+  encode: encode,
+  decode: decode
 };