Category Archives: Android

[Java/Android] 간단하게 사용할수 있는 AES기반 암호화/복호화 유틸

사용자 삽입 이미지
간단하게 사용할 수 있는 암호화 복호화 유틸리티 클래스입니다. 구글링을 통해 찾아낸 방법인데 매우 빠르고 간편하고 가볍게 사용할 수 있습니다.

다음과 같은 방법으로 손쉽게 암호화/복호화를 할 수 있습니다

String CRYPTO_SEED_PASSWORD = "1234!@#$"

SimpleCrypto.encrypt(CRYPTO_SEED_PASSWORD, "암호화를 부탁해요");
SimpleCrypto.decrypt(CRYPTO_SEED_PASSWORD, "복호화를 부탁해요");

굳이 더 설명할 필요는 없을것 같네요. 예제를 첨부하고 이만 줄이겠습니다. [다운로드]

출처: http://www.androidsnippets.com/encryptdecrypt-strings (Thank you!)

[Java/Android] 간단하게 사용하는 Bitmap 리사이즈(Resize) 예제

안드로이드에서 간단하게 Bitmap 이미지를 리사이즈 할 수 있는 메소드를 기억 저장용으로 기록해 둡니다. 리사이즈 하고자 하는 비트맵 이미지와 긴축 최대 길이를 지정하면 긴축에 맞추어 비율에 맞게 리사이즈를 하는 메소드입니다.

/**
 * Bitmap이미지의 가로, 세로 사이즈를 리사이징 한다.
 * 
 * @param source 원본 Bitmap 객체
 * @param maxResolution 제한 해상도
 * @return 리사이즈된 이미지 Bitmap 객체
 */
public Bitmap resizeBitmapImage(Bitmap source, int maxResolution)
{
    int width = source.getWidth();
    int height = source.getHeight();
    int newWidth = width;
    int newHeight = height;
    float rate = 0.0f;

    if(width > height)
    {
        if(maxResolution < width)
        {
            rate = maxResolution / (float) width;
            newHeight = (int) (height * rate);
            newWidth = maxResolution;
        }
    }
    else
    {
        if(maxResolution < height)
        {
            rate = maxResolution / (float) height;
            newWidth = (int) (width * rate);
            newHeight = maxResolution;
        }
    }

    return Bitmap.createScaledBitmap(source, newWidth, newHeight, true);
}