devSunny99
Sunny Develop
devSunny99
์ „์ฒด ๋ฐฉ๋ฌธ์ž
์˜ค๋Š˜
์–ด์ œ
  • ๋ถ„๋ฅ˜ ์ „์ฒด๋ณด๊ธฐ (17)
    • Android (9)
    • objective-c (4)
    • JAVA (1)
    • html&css (0)
    • Git (1)
      • Github (1)
    • ๋ฐฑ์ค€ (2)
      • JAVA (2)

๋ธ”๋กœ๊ทธ ๋ฉ”๋‰ด

  • ํ™ˆ
  • ํƒœ๊ทธ
  • ๋ฐฉ๋ช…๋ก

๊ณต์ง€์‚ฌํ•ญ

์ธ๊ธฐ ๊ธ€

ํƒœ๊ทธ

  • ์•ˆ๋“œ๋กœ์ด๋“œ ๋ฉ”๋ชจ๋ฆฌ๋คํ”„ํ•˜๊ธฐ
  • Android Memory dump
  • ์•ˆ๋“œ๋กœ์ด๋“œapp:debugRuntimeClasspath
  • ์•ˆ๋“œ๋กœ์ด๋“œ String๋ณด์•ˆ์ทจ์•ฝ์ 
  • App Security
  • ์•ˆ๋“œ๋กœ์ด๋“œdependencies์—๋Ÿฌ
  • ์•ˆ๋“œ๋กœ์ด๋“œ ๋ฉ”๋ชจ๋ฆฌ๋คํ”„ ๋ฐฉ๋ฒ•
  • xcode๋””๋ฒ„๊ทธ ๊ธฐ๊ณ„์–ด๋กœ ๋‚˜์˜ด
  • ์•ˆ๋“œ๋กœ์ด๋“œ xml tag has empty body
  • ์•ˆ๋“œ๋กœ์ด๋“œ EditText ๋ฉ”๋ชจ๋ฆฌ๋…ธ์ถœ
  • ์•ˆ๋“œ๋กœ์ด๋“œ xml๊ฒฝ๊ณ 
  • ์•ˆ๋“œ๋กœ์ด๋“œ ๋ฉ”๋ชจ๋ฆฌ ๊ฐ’ ๋ณด๊ธฐ
  • ์•ˆ๋“œ๋กœ์ด๋“œCould not resolve all files for configuration
  • ์•ˆ๋“œ๋กœ์ด๋“œ ๋ฉ”๋ชจ๋ฆฌ ๋คํ”„
  • ์•ˆ๋“œ๋กœ์ด๋“œ xml์—๋Ÿฌ
  • Android Memory Secure
  • android memory security
  • xcode LLDB
  • Android๋ฉ”๋ชจ๋ฆฌ๋…ธ์ถœ
  • ์•ˆ๋“œ๋กœ์ด๋“œ xml ๋…ธ๋ž€์ƒ‰ ํ‘œ์‹œ
  • ์•ˆ๋“œ๋กœ์ด๋“œ xml tag has empty body ํ•ด๊ฒฐ
  • ์•ˆ๋“œ๋กœ์ด๋“œclasspath์—๋Ÿฌ
  • ์•ˆ๋“œ๋กœ์ด๋“œ Profiler์‚ฌ์šฉ๋ฒ•
  • Android String๋ณด์•ˆ์ทจ์•ฝ์ 
  • Android EditText ๋ณด์•ˆ์ทจ์•ฝ์ 
  • ์•ฑ๋ณด์•ˆ
  • xcode๊ธฐ๊ณ„์–ด ๋””๋ฒ„๊น…
  • ์•ˆ๋“œ๋กœ์ด๋“œdebugRuntimeClasspath
  • NSString
  • ์•ˆ๋“œ๋กœ์ด๋“œ xml๋…ธ๋ž€์ƒ‰

์ตœ๊ทผ ๋Œ“๊ธ€

์ตœ๊ทผ ๊ธ€

ํ‹ฐ์Šคํ† ๋ฆฌ

hELLO ยท Designed By ์ •์ƒ์šฐ.
devSunny99

Sunny Develop

JAVA

[JAVA] AES256 ์•”ํ˜ธํ™” ๋ณตํ˜ธํ™”

2022. 9. 7. 22:57

๐Ÿ“ŒAES256Cipher.java

package com.hyesun.aesencdec;

import com.google.firebase.crashlytics.buildtools.reloc.org.apache.commons.codec.binary.Base64;
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.SecretKey;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.InvalidAlgorithmParameterException;

public class AES256Cipher {
    private static volatile AES256Cipher INSTANCE;
    final static String secretKey = "hyesunhyesun99hyesunhyesun99hyes"; //32bit
    static String IV = ""; //16bit
    public static AES256Cipher getInstance() {
        if (INSTANCE == null) {
            synchronized (AES256Cipher.class) {
                if (INSTANCE == null)
                    INSTANCE = new AES256Cipher();
            }
        }
        return INSTANCE;
    }

    private AES256Cipher() {
        IV = secretKey.substring(0, 16);
    }

    //์•”ํ˜ธํ™”
    public static String AES_Encrypt(String str) throws java.io.UnsupportedEncodingException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException, IllegalBlockSizeException, BadPaddingException {
        byte[] keyData = secretKey.getBytes();

        SecretKey secureKey = new SecretKeySpec(keyData, "AES");

        Cipher c = Cipher.getInstance("AES/CBC/PKCS5Padding");
        c.init(Cipher.ENCRYPT_MODE, secureKey, new IvParameterSpec(IV.getBytes()));

        byte[] encrypted = c.doFinal(str.getBytes("UTF-8"));
        String enStr = new String(Base64.encodeBase64(encrypted));

        return enStr;
    }

    //๋ณตํ˜ธํ™”
    public static String AES_Decrypt(String str) throws java.io.UnsupportedEncodingException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException, IllegalBlockSizeException, BadPaddingException {
        byte[] keyData = secretKey.getBytes();
        SecretKey secureKey = new SecretKeySpec(keyData, "AES");
        Cipher c = Cipher.getInstance("AES/CBC/PKCS5Padding");
        c.init(Cipher.DECRYPT_MODE, secureKey, new IvParameterSpec(IV.getBytes("UTF-8")));

        byte[] byteStr = Base64.decodeBase64(str.getBytes());

        return new String(c.doFinal(byteStr), "UTF-8");
    }
}

 

๐Ÿ“Œ์‚ฌ์šฉ์˜ˆ์‹œ

์•”ํ˜ธํ™”
String strTest ="hyesun";
AES256Cipher a256 = AES256Cipher.getInstance();
String strResult = a256.AES_Encrypt(strTest);

 

 

๋ณตํ˜ธํ™”
AES256Cipher a256 = AES256Cipher.getInstance();
String strResult = a256.AES_Decrypt(์•”ํ˜ธํ™”๋œ๋ฌธ์ž์—ด);
    devSunny99
    devSunny99
    ๊ณ ์ˆ˜๋ฅผ ํ–ฅํ•˜์—ฌ ์˜์ฐจ์˜์ฐจโญ๏ธ

    ํ‹ฐ์Šคํ† ๋ฆฌํˆด๋ฐ”