public static void main(String[] args) { String text1 = "강환기"; String text2 = "서울특별시 성북구 화랑로48길16(석관동10) 두산아파트 102동 1002호"; String text3 = "11290-124334"; try { Cryptor aes = new AESCryptor("6c70a0690dd7d923", "UTF-8"); String encode1 = aes.encode(text1); String encode2 = aes.encode(text2); String encode3 = aes.encode(text3); System.out.println("text1 : " + text1); System.out.println("text2 : " + text2); System.out.println("text3 : " + text3); System.out.println("encode1 : " + encode1); System.out.println("encode2 : " + encode2); System.out.println("encode3 : " + encode3); System.out.println("size : " + (encode1.length() + encode2.length() + encode3.length())); String decode1 = aes.decode(encode1); String decode2 = aes.decode(encode2); String decode3 = aes.decode(encode3); System.out.println("decode1 : " + decode1); System.out.println("decode2 : " + decode2); System.out.println("decode3 : " + decode3); System.out.println("size : " + (decode1.length() + decode2.length() + decode3.length())); } catch (Exception e) { e.printStackTrace(); } }
/** * This class can be called with "encrypt" password as the arguments where encrypt is a literal * and password is replaced with the clear text password to be encrypted. * * @param args The arguments in the form "command" parm1, parm2. * @throws Exception If an error occurs. */ public static void main(String[] args) throws Exception { if (args.length != 2 || !(args[0].equals("encrypt"))) { System.err.println("Usage: \"EncryptUtil encrypt\" password"); System.err.println(" password : The clear text password to encrypt"); System.exit(0); } Cryptor cryptor = CryptorFactory.getCryptor(); if (args[0].equals("encrypt")) { System.out.println(cryptor.encrypt(args[1])); } }
@Override @SuppressWarnings("ResourceType") protected void setUp() throws Exception { super.setUp(); preferences = mock(SharedPreferences.class); when(preferences.getBoolean(eq(KEY_PREF_SERVICE_ENABLED), anyBoolean())).thenReturn(true); when(preferences.getBoolean(eq(KEY_PREF_SERVICE_ENABLED), anyBoolean())).thenReturn(true); when(preferences.getString(eq(KEY_PREF_SENDER_ACCOUNT), anyString())) .thenReturn("*****@*****.**"); when(preferences.getString(eq(KEY_PREF_SENDER_PASSWORD), anyString())).thenReturn("password"); when(preferences.getString(eq(KEY_PREF_RECIPIENTS_ADDRESS), anyString())) .thenReturn("*****@*****.**"); when(preferences.getString(eq(KEY_PREF_EMAIL_HOST), anyString())).thenReturn("smtp.mail.com"); when(preferences.getString(eq(KEY_PREF_EMAIL_PORT), anyString())).thenReturn("111"); when(preferences.getStringSet(eq(KEY_PREF_EMAIL_TRIGGERS), anySetOf(String.class))) .thenReturn(DEFAULT_TRIGGERS); when(preferences.getStringSet(eq(KEY_PREF_EMAIL_CONTENT), anySetOf(String.class))) .thenReturn(DEFAULT_CONTENT); networkInfo = mock(NetworkInfo.class); when(networkInfo.isConnected()).thenReturn(true); ConnectivityManager connectivityManager = mock(ConnectivityManager.class); when(connectivityManager.getActiveNetworkInfo()).thenReturn(networkInfo); context = mock(Context.class); when(context.getSystemService(eq(Context.CONNECTIVITY_SERVICE))) .thenReturn(connectivityManager); when(context.getContentResolver()).thenReturn(getContext().getContentResolver()); when(context.getResources()).thenReturn(getContext().getResources()); when(context.getSharedPreferences(anyString(), anyInt())).thenReturn(preferences); database = new Database(getContext(), "test.sqlite"); /* not mock context */ database.destroy(); cryptor = mock(Cryptor.class); when(cryptor.decrypt(anyString())) .then( new Answer<String>() { @Override public String answer(InvocationOnMock invocation) throws Throwable { return "decrypted " + invocation.getArguments()[0]; } }); transport = mock(MailTransport.class); notifications = mock(Notifications.class); }