Hyperledger Fabric SDK

Hyperledger Fabric은 다양한 프로그래밍 언어를 지원하는 여러 SDK를 제공합니다. 

Node.js와 Java에는 공식적으로 출시 된 SDK가 두 가지 있습니다.

또한 공식적으로 아직 출시되지 않은 Python, Go 및 REST 용 SDK가 세 가지 더 있지만, 다음과 같이 다운로드하여 테스트 할 수 있습니다.

AND

1. #는 쿼리가 수행될 때, 다음과 같이 된다 

 

SELECT * FROM USER 

WHERE 

col = ?  

 

 

parameter : [값]

 

?에 bind된 값이 들어가게 된다. 

 

이 쿼리 컴파일 된 내용을 재사용 할 수 있고, 파라미터에 따라 대입해주므로 효율적이다.

내부적으로 preparedStatement 객체에서 ? 에 들어갈 파라미터의 값을 set 해줌으로써 사용이 된다.

 

preparedStatement는 한번 수행한 쿼리를 캐싱하는 객체

 

 

사용 용도 >>

 

#일 경우, 에 사용한다.

 

myBatis : 컬럼명 = #{값}   

iBatis : 컬럼명 = #값#

 

* 쿼리에 작은 따옴표가 붙게 된다.

 

 

2. $는 쿼리가 수행될 때, 다음과 같이 된다

 

SELECT * FROM USER

WHERE 

col = 

 

 

값이 넣어진 쿼리 자체로 수행이 된다.(상수)

즉, 문장 전체가 preparedStatement가 된다.

 

사용 용도 >>

 

$일 경우는 컬럼명이 동적으로 바뀌어야 할 때 사용한다. 또는 테이블명.

 

myBatis : ${컬럼명} = #{값}   

iBatis : $컬럼명$ = #{값}

 

* 쿼리에 작은따옴표가 붙지 않는다. 

값에 $를 사용하면 스트링의 경우 작은따옴표로 감싸지지 않기 때문에 에러 발생한다.

 

 

이렇게 사용하지 않으면 unknown column 이나 There is no readable property named  등등의 에러가 뜨게 된다



AND

AES 암복호화 구현 클래스 입니다.

암호문생성은 aesEncode, 복호화는 aesDecode 함수를 호출하면 됩니다

 

import java.io.UnsupportedEncodingException;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.Key;
import java.security.NoSuchAlgorithmException;
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import org.apache.commons.codec.binary.Base64;

public class AESUtil {

/*

parameter :

      str - 원문

      key - 키값

*/
    public static String aesEncode(String str, String key) throws UnsupportedEncodingException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException, IllegalBlockSizeException, BadPaddingException {
        String iv = key.substring(0, 16);
        byte[] keyBytes = new byte[16];
        byte[] b = key.getBytes("UTF-8");
        int len = b.length;
        if (len > keyBytes.length) {
            len = keyBytes.length;
        }
        System.arraycopy(b, 0, keyBytes, 0, len);
        SecretKeySpec keySpec = new SecretKeySpec(keyBytes, "AES");
        Cipher c = Cipher.getInstance("AES/CBC/PKCS5Padding");
        c.init(1, (Key)keySpec, new IvParameterSpec(iv.getBytes()));
        byte[] encrypted = c.doFinal(str.getBytes("UTF-8"));
        String enStr = new String(Base64.encodeBase64((byte[])encrypted));
        return enStr;
    }


    /*

    parameter :

      str - 암호문 (BASE64)

      key - 키값

   */


    public static String aesDecode(String str, String key) throws UnsupportedEncodingException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException, IllegalBlockSizeException, BadPaddingException {
        String iv = key.substring(0, 16);
        byte[] keyBytes = new byte[16];
        byte[] b = key.getBytes("UTF-8");
        int len = b.length;
        if (len > keyBytes.length) {
            len = keyBytes.length;
        }
        System.arraycopy(b, 0, keyBytes, 0, len);
        SecretKeySpec keySpec = new SecretKeySpec(keyBytes, "AES");
        Cipher c = Cipher.getInstance("AES/CBC/PKCS5Padding");
        c.init(2, (Key)keySpec, new IvParameterSpec(iv.getBytes("UTF-8")));
        byte[] byteStr = Base64.decodeBase64((byte[])str.getBytes());
        return new String(c.doFinal(byteStr), "UTF-8");
    }
}

 

https://link.coupang.com/a/Ne1xR

 

LG전자 톤프리 돌비 애트모스 무선 블루투스 이어폰

COUPANG

www.coupang.com

이 포스팅은 쿠팡 파트너스 활동의 일환으로, 이에 따른 일정액의 수수료를 제공받습니다.

AND

/*

Byte[] 이미지데이타를 png 이미지 파일

*/

ByteArrayInputStream input_stream= new ByteArrayInputStream(imgByte);

BufferedImage final_buffered_image = ImageIO.read(input_stream);

ImageIO.write(final_buffered_image , "png", new File("./temp.png") );

AND

public static void sort(File[] filterResult) {

   // 파일명으로 정렬한다. 

    Arrays.sort(filterResult, new Comparator() {

         public int compare(Object arg0, Object arg1) {

               File file1 = (File)arg0;

               File file2 = (File)arg1;

               return file1.getName().compareToIgnoreCase(file2.getName());

         }

   });

}

 

사용예시 : 특정 폴더의 파일명으로 정렬하여 화면에 출력


String   strFileDir = "/temp/";
File dirFile=new File(strFileDir);
File[] fileList=dirFile.listFiles();

if (fileList != null)
{

   sort(fileList);

  for(File tempFile : fileList) {
      if(tempFile.isFile()) {
         String tempFileName=tempFile.getName();
         System.out.println(tempFileName)
      }
     }

}

AND