test_class.declarator: logger = LoggerFactory.getLogger(EncryptUtilTest.class)
test_class.modifier: private static final
test_class.original_string: private static final Logger logger = LoggerFactory.getLogger(EncryptUtilTest.class);
test_class.type: Logger
test_class.var_name: logger
test_class.declarator: KEY = "$%!*?t12"
test_class.modifier: private static final
test_class.original_string: private static final String KEY = "$%!*?t12";
test_class.type: String
test_class.var_name: KEY
test_class.declarator: SAMPLE1 = "test"
test_class.modifier: private static final
test_class.original_string: private static final String SAMPLE1 = "test";
test_class.type: String
test_class.var_name: SAMPLE1
test_class.declarator: SAMPLE2 = "hello world"
test_class.modifier: private static final
test_class.original_string: private static final String SAMPLE2 = "hello world";
test_class.type: String
test_class.var_name: SAMPLE2
test_class.declarator: SAMPLE3 = "this is going to be a super long string that has spaces, etc. and ! I'm really happy that I'll be testing the MD5 hash to its fullest!!!!"
test_class.modifier: private static final
test_class.original_string: private static final String SAMPLE3 = "this is going to be a super long string that has spaces, etc. and ! I'm really happy that I'll be testing the MD5 hash to its fullest!!!!";
test_class.type: String
test_class.var_name: SAMPLE3
test_class.declarator: SAMPLE1_ENC = "K5Ygd3D1N+8="
test_class.modifier: private static final
test_class.original_string: private static final String SAMPLE1_ENC = "K5Ygd3D1N+8=";
test_class.type: String
test_class.var_name: SAMPLE1_ENC
test_class.declarator: SAMPLE2_ENC = "TtJn7HMA9ww4xeJC7HCZhQ=="
test_class.modifier: private static final
test_class.original_string: private static final String SAMPLE2_ENC = "TtJn7HMA9ww4xeJC7HCZhQ==";
test_class.type: String
test_class.var_name: SAMPLE2_ENC
test_class.declarator: SAMPLE3_ENC = "weXM56gYEglEtqRI/oOnhtawCRZG00aEfGxTgjysBZ08SZTRXhwhA7LrCklQ3WXGFi0oYlz0ACI7xneN4/P35JKCxMj+MNJS4spazdWFuIrryRqaUk/87KY39ve56nxqN31jC058guUPk4BglDpLIq9uyywv9vAlKnuXCMmDMjuyjBAuPqEoJYTzP7ObGhAJ"
test_class.modifier: private static final
test_class.original_string: private static final String SAMPLE3_ENC = "weXM56gYEglEtqRI/oOnhtawCRZG00aEfGxTgjysBZ08SZTRXhwhA7LrCklQ3WXGFi0oYlz0ACI7xneN4/P35JKCxMj+MNJS4spazdWFuIrryRqaUk/87KY39ve56nxqN31jC058guUPk4BglDpLIq9uyywv9vAlKnuXCMmDMjuyjBAuPqEoJYTzP7ObGhAJ";
test_class.type: String
test_class.var_name: SAMPLE3_ENC
test_class.file: ch-commons-util/src/test/java/com/cloudhopper/commons/util/EncryptUtilTest.java
test_class.identifier: EncryptUtilTest
test_case.body: @Test
      public void encrypt() throws Exception {
          String string0 = EncryptUtil.encrypt(KEY, SAMPLE1);
          Assert.assertEquals(SAMPLE1_ENC, string0);
          //logger.debug(string0);
          string0 = EncryptUtil.encrypt(KEY, SAMPLE2);
          Assert.assertEquals(SAMPLE2_ENC, string0);
          //logger.debug(string0);
          string0 = EncryptUtil.encrypt(KEY, SAMPLE3);
          Assert.assertEquals(SAMPLE3_ENC, string0);
          //logger.debug(string0);
      }
test_case.class_method_signature: EncryptUtilTest.encrypt()
test_case.full_signature: @Test public void encrypt()
test_case.identifier: encrypt
test_case.invocations: encrypt assertEquals encrypt assertEquals encrypt assertEquals
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void encrypt()
focal_class.file: ch-commons-util/src/main/java/com/cloudhopper/commons/util/EncryptUtil.java
focal_class.identifier: EncryptUtil
focal_class.class_method_signature: EncryptUtil.generateKey()
focal_class.full_signature: public static String generateKey()
focal_class.identifier: generateKey
focal_class.modifiers: public static
focal_class.parameters: ()
focal_class.return: String
focal_class.signature: String generateKey()
focal_class.class_method_signature: EncryptUtil.encrypt(String key, String source)
focal_class.full_signature: public static String encrypt(String key, String source)
focal_class.identifier: encrypt
focal_class.modifiers: public static
focal_class.parameters: (String key, String source)
focal_class.return: String
focal_class.signature: String encrypt(String key, String source)
focal_class.class_method_signature: EncryptUtil.decrypt(String key, String source)
focal_class.full_signature: public static String decrypt(String key, String source)
focal_class.identifier: decrypt
focal_class.modifiers: public static
focal_class.parameters: (String key, String source)
focal_class.return: String
focal_class.signature: String decrypt(String key, String source)
focal_class.class_method_signature: EncryptUtil.getKey(String key)
focal_class.full_signature: private static Key getKey(String key)
focal_class.identifier: getKey
focal_class.modifiers: private static
focal_class.parameters: (String key)
focal_class.return: Key
focal_class.signature: Key getKey(String key)
focal_method.body: public static String encrypt(String key, String source) {
          try {
              // Get our secret key
              Key key0 = getKey(key);
              // Create the cipher
              Cipher desCipher = Cipher.getInstance("DES/ECB/PKCS5Padding");
              // Initialize the cipher for encryption
              desCipher.init(Cipher.ENCRYPT_MODE, key0);
              // Our cleartext as bytes
              byte[] cleartext = source.getBytes();
              // Encrypt the cleartext
              byte[] ciphertext = desCipher.doFinal(cleartext);
              // convert to Base64
              //byte[] b64cipherText = Base64.encodeBase64(ciphertext);
              // Return a String representation of the cipher text
              //return StringUtil.getAsciiString(b64cipherText);
              // replaced Jakarta Base64 with custom one
              return Base64Codec.encode(ciphertext);
          } catch (Exception e) {
              throw new RuntimeException(e.getMessage());
          }
      }
focal_method.class_method_signature: EncryptUtil.encrypt(String key, String source)
focal_method.full_signature: public static String encrypt(String key, String source)
focal_method.identifier: encrypt
focal_method.invocations: getKey getInstance init getBytes doFinal encode getMessage
focal_method.modifiers: public static
focal_method.parameters: (String key, String source)
focal_method.return: String
focal_method.signature: String encrypt(String key, String source)