비트코인 지갑

블록체인 2018. 2. 1. 23:07

 REF

 비트코인 지갑 : 처음들으면 Bitcoin이 들어있는 것으로 착각들을 하지만, 실제로는 private키만 보관한다.

   종류는 인터넷에 연결된 Hot Wallet과  그렇지 않은 Cold Wallet이 있고 ,   HD(계층 결정적)Wallet도 참고삼아 보자.


  Hot Wallet - full node에는 full wallet,  SPV Node에는 SPV(Simple Payment Verification) wallet. 

                     전체 blockchain을 저장하지 않으면서 full node들의 메모리를 이용하는 가벼운 장점으로 인해, 모바일을 비롯해 많은 SPV wallet들이 발전중이다.


  Cold Wallet - 종이나 USB 혹은 특별히 제작된 Hardware와 같이 offline으로 private key를 저장하는 Wallet.




  HD Wallet - 24개 이하의 단어를 쓰면 private key를 생성해줘서 약간 외울수 있는 수준의 private key를 만들어 주는 지갑.

             brain Wallet도 비슷한 개념인거 같네요.   암튼 이것도 단어는 추측이 쉬워서 보안에 취약하다는 거...  

        정리하면) 단어를 이용해 pk를 만들거나 단어를 통해 pk를 암기하는 방식으로 pk를 안외워도 되는 방식이지만 보안에 썩 좋진 않음

        ==> 그래도  왠지 이게 끌리네요. 가성비가 좋을듯. 



 -------------  private key를 보관하지 않는 wallet --------  비트코인 지갑이라고 부를수 없을것 같구요

  Web Wallet- pk를 3자에게 맡긴 것으로, 거래소 등에 Wallet을 맡겼다고 보면 된다.  당근 위험!  

Posted by yongary
,

jQuery의 팝업 기능으로 간단히 이쁜 layer팝업을 만들수 있다.

 - 이걸 모를때는 bootstrap을 사용했었는데, jQuery가 더 편하다.

  (이쁘기는 bootstrap이 더 이쁠 것 같아요)



- 사용법도 간단하다.  REF


1. jquery관련 인클루드

  <script type="text/javascript" src="blabla/js/jquery.popup.min.js"></script>


2. html 팝업코딩

  <div id="popup" class="pop_style">

     blabla

  

3. jquery로 호출.

  뛰우기:  $('#popup').bPopup();


  close:   $('#popup').bPopup().close();

Posted by yongary
,

Excel upload

springBoot gradle 2018. 1. 23. 11:46

 poi 이용 : 한글 REF 

    영문: REF



1. maven dependency 추가.

<dependency>

<groupId>org.apache.poi</groupId>

<artifactId>poi</artifactId>

<version>3.15</version>

</dependency>

         <dependency>

            <groupId>org.apache.poi</groupId>

            <artifactId>poi-ooxml</artifactId>

            <version>3.15</version>

        </dependency>

<dependency>

            <groupId>org.apache.poi</groupId>

            <artifactId>poi-ooxml-schemas</artifactId>

            <version>3.15</version>

        </dependency>

        <dependency>

            <groupId>org.apache.poi</groupId>

            <artifactId>poi-contrib</artifactId>

            <version>3.6</version>

        </dependency>


2. JSP

function fnCheckUpload() {

var file = $("#excel").val();

if(file == "" || file == null){

alert("먼저 파일을 선택하세요.");

return false;

}

var fileFormat = file.split(".");

var fileType = fileFormat[1];

if(confirm("업로드 하시겠습니까?")){

$('#excelUpForm').attr('action','/uploadMoveinExcel.do');

var options = {

fail:function(data) {

        alert('저장 오류가 발행하였습니다.');

        $('#popup').bPopup().close();

        },

success:function(data){

alert(data + "건 업로드 완료");

$('#popup').bPopup().close();

},

type: "POST",

data : {"excelType" : fileType}

};

$('#excelUpForm').ajaxSubmit(options);

}

}

-----HTML--------

<form id="excelUpForm" method="post" action="" role="form" enctype="multipart/form-data">

                                    <input  id="excel" name="excel" class="file" type="file"  >


</form>



3. controller

  @ResponseBody

@RequestMapping(value="/uploadMoveinExcel.do")

public String uploadExcel( MultipartHttpServletRequest request, HttpSession session) {

List<ExcelVo> list = new ArrayList<>();

String excelType = request.getParameter("excelType");

log.info("uploadExcel.do + excelType:" + excelType);

if(excelType.equals("xls")){

list = moveinService.xlsExcelReader(request);

}else if(excelType.equals("xlsx")){

//IN_STUDY:  list = adminAccountsMngService.xlsxExcelReader(req);

}

int cnt = service.uploadList(list);

return String.valueOf(cnt);//success cnt : media처리의 경우, JSON포맷으로 잘 안변함(config필요), 따라서 간단히 숫자만 리턴.

}


4. service

  public List<MoveinExcelVo> xlsExcelReader(MultipartHttpServletRequest request) {

// 반환할 객체를 생성

List<MoveinExcelVo> list = new ArrayList<>();


MultipartFile file = request.getFile("excel");

HSSFWorkbook workbook = null;


try {

// HSSFWorkbook은 엑셀파일 전체 내용을 담고 있는 객체

workbook = new HSSFWorkbook(file.getInputStream());


// 0번째 sheet 반환

HSSFSheet curSheet = workbook.getSheetAt(0);  //workbook.getNumberOfSheets()

// row 탐색 for문

boolean isInTable = false;

for (int rowIndex = 0; rowIndex < curSheet.getPhysicalNumberOfRows(); rowIndex++) {

//헤더 Cell 찾기.

String firstCellValue = curSheet.getRow(rowIndex).getCell(0).getStringCellValue();

if ("구분".equals(firstCellValue.trim())) { //table헤더 발견.

isInTable = true;

continue; //헤더는 pass.  (다움줊부터 paring시작.)

}

if (isInTable) { //in Table 파싱 시작. ///////////////////////////////////////////

HSSFRow curRow = curSheet.getRow(rowIndex);

//필수 Cell들.

String cellStr = curRow.getCell(2).getStringCellValue(); //String 읽기

String cellDate =  StringUtil.toYYMMDD(curRow.getCell(5).getDateCellValue()); //날짜 읽기

String cellNum = curRow.getCell(7).getNumericCellValue() + ""; //산차.

  String cellLongNUm = StringUtil.toIntString(curRow.getCell(12).getNumericCellValue() ;   //엄청 긴 숫자 읽기

. . . . 

} catch (IOException e) {

e.printStackTrace();

}


// vo로 만들면서 db에 삽입코드는 생략.

return list;

}


public class StringUtil {


    private static SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");

    public static String datePattern = "^\\d{4}[\\-](0[1-9]|1[012])[\\-](0[1-9]|[12][0-9]|3[01])$";

    public static boolean isDate(String str) {

    return Pattern.matches(datePattern, str);

    }

    //return YYYY-MM-DD String

    public static String toYYMMDD(Date date) {

    return formatter.format(date);

    }

    public static boolean isNumericOrFloat(String str) {

        if (str == null) {

            return false;

        }

        int sz = str.length();

        for (int i = 0; i < sz; i++) {

            if (Character.isDigit(str.charAt(i)) == false) {

            if (str.charAt(i) != '.')  //Added KY. '.'도 numeric으로 간주. float때문에.

            return false;

            }

        }

        return true;

    }

    

    //For Excel processing.

    // 엑셀에선 숫자를 항상 double로 읽기 때문에 int형태의 String으로 변환하면 유용.

    public static String toIntString(double doubleVal) {

    try {

    BigInteger k = new BigDecimal(doubleVal).toBigInteger();

    

    return String.valueOf(k);

   

    } catch (Exception e) {

    return null;

    }

    }

Posted by yongary
,

특수기능

ElasticSearch 2018. 1. 22. 21:38

template: 여러개의 template을 지정해 놓을 수 있음.

     -> 잘못 사용하면 여기에 계속 걸려서, insert가 안되는 경우도 있으니 조심필요.



join: 부모-child관계 지정.   (예:질문-답변)  REF

       RDB의 relation과 어느정도는 유사하게 사용이 가능하지만,

       one-to-many 관계에서만 사용하는 게 좋다. 

       (그리고, 한 index안에서만 사용한다 )


 -Relation: 부모와 자식관계 설정

 -Child 여러 개 설정 가능

- (손자)Child 밑에 Child를 둘 수 있음





_segment: segment내의 data까지 조회가 가능하다.





Posted by yongary
,

js 모듈화 코딩기법

jquery 2018. 1. 2. 09:14

http://www.nextree.co.kr/p4150/  

Posted by yongary
,

기본 Query예제

ElasticSearch 2017. 12. 31. 08:22


kibana필터 기본 문법:   REF - 루씬 문법임. . 

     title:(+return +"pink panther") : Field grouping - REF

  

timeliion 문법: REF



== 그 외 아래는 elastic 기본 Query예제이다. ====================================

 



  Index데이타넣기 + 자동생성 : REF


PUT /twitter
/doc/1 (1은 생략시 자동생성) { "user" : "kimchy", "post_date" : "2009-11-15T14:12:12", "message" : "trying out Elasticsearch" }



Index 생성 및 Mapping 조정: REF

PUT twitter :생성 {} PUT twitter/_mapping/_doc { "properties": { "name": { "type": "text" } } } //type:keyword가 중요

데이타 타입: REF



문서하나 Delete:

    DELETE /twitter/_doc/1

   


 Delete Index:

 DELETE /twitter






  Match:  REF


GET entry/_search

{

  "query": {

    "term": {"play_name":"Hamlet"}

  }

}


GET entry


GET /_search { "query": { "match" : { "message" : "this is a test" } } }



Posted by yongary
,

랜섬웨어 감염시

IT 2017. 12. 30. 10:22

랜섬웨어에 감염되어 파일들이 확장자가 변경되면서 실행이 안된다면..


1. windows/system32/tasks  밑에 가서, 날짜를 보고 최근 것들을 지운다.

  => 랜섬웨어 동작을 멈추게 한다.

  (그 후 고클린 등으로 각종 clear작업을 해주면 더 좋다)


2. 이미 감염된 파일들은 복구가 불가능 한데, 

   https://www.nomoreransom.org/ko/index.html   여기에 가면 일부 복구가 되는 랜섬들이 나열되어 있으므로

   따라서 복구를 한다.

Posted by yongary
,

spring boot로 Web Project생성하기.


1. https://start.spring.io/  에 접속해서  maven/gradle을 선택하고 이름만 넣으면  springboot프로젝트를 생성할 수 있다.  

   => 일반 application이 생성된다.


  1.1  IDEA나 eclipse에서 import project를 해서 열어서 Run만 시키면 돌아간다. (아래과 같이 spring을 볼수 있다)

    .   ____          _            __ _ _

 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \

( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \

 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )

  '  |____| .__|_| |_|_| |_\__, | / / / /

 =========|_|==============|___/=/_/_/_/

 :: Spring Boot ::        (v1.5.9.RELEASE)



2. Build.gradle을 열어서  아래 한줄을 추가한다.   (JDK1.8기준)


compile group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: '1.4.7.RELEASE'
(version: '1.4.7.RELEASE')

 

   ==> 자동으로 Web Application이 된다. 실행도 되고 localhost:8080 접속도 된다.


3.  jsp처리기능이 아직없으므로 이를 위해 2개 더 추가한다. (REF1, ) 

    

compile group: 'javax.servlet', name: 'jstl', version: '1.2'
compile group: 'org.apache.tomcat.embed', name: 'tomcat-embed-core', version: '8.5.24'
compile group: 'org.apache.tomcat.embed', name: 'tomcat-embed-jasper', version: '8.5.24'

   

     (그리고, resources밑에 있는 application.property에  아래 4번 경로와 suffix를 추가한다)

     


spring.mvc.view.prefix=/WEB-INF/views/
spring.mvc.view.suffix=.jsp



4.  src/main  밑에  /webapp/views  밑에    jsp생성  (REF2-jsp) 

     
  jsp첫줄에는 아래 한줄이 필요하고..

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>

 그 후 <html> tag야 있으면 좋고..





별첨: 간단한 Junit4 Test코드.... + RestTemplate는 여기 참조:   REF

         Lombok사용시 - 설정에서 컴파일러 옵션 중 Annotation Process 체크필요.

Posted by yongary
,

MVC개념

springBoot gradle 2017. 12. 29. 21:56

      USER가 url을 요청한다던지 하는 action을 하면, controller가 받아서 

     Model을 조회/변경하고 그걸 다시
     View에서 그려준다.  


    3가지가 분리되어서 업무분리 개발분리가 가능해진다. 

Posted by yongary
,

1. 해시캐시 (HashCache)

   - 해시함수를 fn(X) = Y 로 표현한다면, X는 입력값 Y는 출력값이다.
     이 중에서 이쁜 Y를 만들기 위해 X를 바꿔가며 입력할 수 있는데, 
     이쁜 Y를 만든 X를 HashCache라고 부를 수 있다.
    

     그런데 X에는 자동으로 고정되는 값이 몇개 포함되어 있어야 하고, 
     사용자가 임의로 설정할 수 있는 값도 있어야 한다.

     즉, 수신자의 메일주소와 같이 바꿀 수 없는 값 + 사용자가 임의설정 가능한 카운터 = X로 했을때
     이쁜 Y를 만들 수 있는 X를  HashCache라고 부를 수 있다.


     (해시캐시의 개념은 스팸메일 필터링에서 나온 개념이므로 수신자의 메일주소를 주로 포함한다.

     90년대 국제표준에서는 Y의 앞자리20자리가 0이 되는 X값을 해쉬캐시로 정했었다.)



2. Nonce
   - 위 예제에서 사용자가 설정한 임의의 카운터를 Nonce라고 부를수 있다.  나머지 고정된 값들을 제외한 사용자가 

      고생을 해서 산출해야 하는 값이다.

   - 이쁜 Y라고 부르는 이유는, Y값의 범위를 정하거나 모양등을 정하므로서, 알고리듬의 복잡도가 탄생한다. 

      즉, Y값을 000000000xxxxxxx 이런식으로 고정한다면, 이를 위해서 사용자는 nonce를 여러번 생성해봐야지 적당한 nonce를 구할 수 있다.

   - 비트코인에서는 총32Byte(256bit) 중,  앞자리 40 bit가 0이어야 한다.



이러한 해시캐시(Nonce포함)개념으로 하나의 블록을 생성한다. 


3. 블록체인

  - 앞에서 설명한 하나의 블록을 여러개 연결한게 블록체인이다.

  - 연결방식은 뉴블록 = 직전블록의 Hash값 +  뉴데이타 + 뉴Nonce 이다.   

   - 뉴뉴블록 = 뉴블록 Hash값 + 뉴뉴data + 뉴뉴nonce로  항상 직전 Hash값만 포함한다.

     이것만으로도 이전의 모든 블록들을 마치 다 포함하는 것처럼, 앞 선 모든 블록들을 아무도 고치지 못하는 효과가 생긴다. 


 

  




Posted by yongary
,