class AESCipher:

    BLOCK_SIZE = 16

    class PKCS7Encoder():
        class InvalidBlockSizeError(Exception):
            """Raised for invalid block sizes"""
            pass

        def __init__(self, block_size=16):
            if block_size < 2 or block_size > 255:
                raise AESCipher.PKCS7Encoder.InvalidBlockSizeError('The block size must be ' \
                        'between 2 and 255, inclusive')
            self.block_size = block_size

        def encode(self, text):
            text_length = len(text)
            amount_to_pad = self.block_size - (text_length % self.block_size)
            if amount_to_pad == 0:
                amount_to_pad = self.block_size
            pad = chr(amount_to_pad)
            return text + pad * amount_to_pad

        def decode(self, text):
            pad = text[-1]
            return text[:-pad]

    def __init__(self, key, iv):
        self.key = key
        self.iv = iv
        self.encoder = AESCipher.PKCS7Encoder(AESCipher.BLOCK_SIZE)

    def encrypt(self, raw):
        data = self.encoder.encode(raw)
        cipher = AES.new(self.key, AES.MODE_CBC, self.iv.encode("utf-8"))
        return cipher.encrypt(data)

    def decrypt(self, enc):
        cipher = AES.new(self.key, AES.MODE_CBC, self.iv.encode("utf-8"))
        return self.encoder.decode(cipher.decrypt(enc))


구글링으로 여기저기서 조합한 코드다. (출처가 없음은 죄송..)



C#(unity3D) : Padding 알고리즘을 선택할 수 있다

NodeJs : final() 호출하면 알아서 해준다.

Python : 따로 일일이 해줘야 한다.


검색했던 키워드는 python, AES, encryption, pkcs7 padding



python2 와 python3는 문자열, 바이트 처리 방식이 다른 듯 하다.

decode() 안에서 ord()를 사용했는데 python3 넘어오자 그게 필요 없어졌다.


=> TypeError: ord() expected string of length 1, but int found



encrypt 되서 나온 결과물은 base64로 변환해서 전송하는 것이 보통

'Develop' 카테고리의 다른 글

WPF Binding  (0) 2018.11.12
perforce ignore  (0) 2018.09.05
nodejs zip  (0) 2018.02.27
mac 에서 logcat  (0) 2018.02.22
vscode 지금업데이트 안됨  (0) 2017.09.18
import * as fs from 'fs';
import * as JSZip from 'jszip';

let jszip = new JSZip();

jszip.file("aaa.txt", 'aaaa');
jszip.file("bbb.txt", 'bbbb');
jszip.file("ccc.txt", 'cccc');

jszip.generateNodeStream({ type: 'nodebuffer', streamFiles: true })
.pipe(fs.createWriteStream('out.zip'))
.on('finish', function () {
console.log('out.zip');
fs.readFile('out.zip', function (err, data) {
if (err) throw err;
jszip.loadAsync(data).then(async function (zip) {
console.log(zip);
for(let key in zip.files){
console.log(await jszip.file(key).async('text'));
}
});
});
});


여러개의 파일을 압축하고, 다시 압축 푸는것


jszip 공식 홈페이지

http://stuk.github.io/jszip/documentation/examples.html

'Develop' 카테고리의 다른 글

perforce ignore  (0) 2018.09.05
python AES 암호화  (0) 2018.05.17
mac 에서 logcat  (0) 2018.02.22
vscode 지금업데이트 안됨  (0) 2017.09.18
aws lambda express.js 세팅기  (0) 2017.08.23

android studio 안에서 GUI로 보길 원했으나, 

찾을수가 없음.

android studio 공식 홈페이지 에서는 캡쳐화면이 있는데 못찾겠음.


구글링을 해보니 adb logcat 이라고 하라는데,

terminal에서 adb 인식을 못한다.


android sdk를 설치하면 adb가 같이 설치 된다. (옵션 선택 가능)


위치는

/Users/유저홈폴더/Library/Android/sdk/platform-tools


path를 지정해주고

이제부터

adb logcat 하면 로그가 왕창 나온다.


필터링은 구글링을...



  • 우선순위는 다음 문자값 중 하나이며, 가장 낮은 우선순위에서 가장 높은 우선순위로 지정됩니다.
    • V — Verbose (가장 낮은 우선순위)
    • D — Debug
    • I — Info
    • W — Warning
    • E — Error
    • F — Fatal
    • S — Silent(가장 높은 순위, 이 경우 아무 것도 출력되지 않음)
adb logcat *:W


'Develop' 카테고리의 다른 글

python AES 암호화  (0) 2018.05.17
nodejs zip  (0) 2018.02.27
vscode 지금업데이트 안됨  (0) 2017.09.18
aws lambda express.js 세팅기  (0) 2017.08.23
xCode Build error GoogleSignIn/GIDSignIn.h file not found  (0) 2017.05.30

다른 사람이 사용하면 mac에서 

사용자만 새로 만들어서 사용하고 있었다.


vscode 업데이트가 있을 때

지금 업데이트 버튼을 누르고

아무 반응이 없다.


vscode의 권한을 보니

drwxr-xr-x   3 paul  staff    102  9 18 17:01 Visual Studio Code.app


gruop이 staff이 되어 있다.


sudo chown -R paul:admin "/Applications/Visual Studio Code.app"

sudo chown -R paul:admin ~/Library/Caches/com.microsoft.VSCode

sudo chown -R paul:admin ~/Library/Caches/com.microsoft.VSCode.ShipIt


하면 잘된다


하지만 업데이트를 하고 나면


다시 staff으로 바뀐다.

  /Applications dscl . -read /Groups/staff

AppleMetaNodeLocation: /Local/Default

GeneratedUID: ABCDEFAB-CDEF-ABCD-EFAB-CDEF00000014

GroupMembers: FFFFEEEE-DDDD-CCCC-BBBB-AAAA00000000

GroupMembership: root

Password: *

PrimaryGroupID: 20

RealName: Staff

RecordName: staff BUILTIN\Users

RecordType: dsRecTypeStandard:Groups

SMBSID: S-1-5-32-545


staff의 정보를 보니 내 이름이 빠져 있다.


sudo dscl . -append /Groups/staff GroupMembership paul


이걸로 나의 이름을 그룹에 넣어줬다.


다음 업데이트가 있을 때 잘되는지 확인후 업데이트 하겠음.



'Develop' 카테고리의 다른 글

nodejs zip  (0) 2018.02.27
mac 에서 logcat  (0) 2018.02.22
aws lambda express.js 세팅기  (0) 2017.08.23
xCode Build error GoogleSignIn/GIDSignIn.h file not found  (0) 2017.05.30
unity3d black screen  (0) 2017.03.22

aws에 lambda에 node.js를 붙일수 있는건 알겠는데 

핸들러를 하나씩 등록해야 한다.


express.js를 사용해서 만든 게임서버를 붙여보고 싶다.


keyword는 serverless


awslabs 에서 serverless-express 예제를 만들어 놨다. (링크)


예제를 따라가면.

1. git clone https://github.com/awslabs/aws-serverless-express.git && cd aws-serverless-express/example

2. npm run config -- --account-id="123456789012" --bucket-name="my-unique-bucket"

account-id는 support 메뉴에 있다. (링크)

3. package.jsonsimple-proxy-api.yaml and cloudformation.yaml 에 텍스트 교체 (꼼꼼하게 체크)

4. npm run setup

1. aws cli 설치가 안되어 있으면 에러가 난다. (링크)

2. aws cli은 pip로 설치 해야 한다. (링크)

3. 링크에서 받은 패키지로 설치하면 /Library/Frameworks/Python.framework/Versions/3.6 경로에 설치된다

4. pip3.6 install awscli

5. Unable to locate credentials 에러가 뜬다면 credentials 세팅을 해야 한다

- aws 에서 다운받은 accesskey.csv의 내용을 이용하여

- aws configure

6. s3의 정책 생성 (생성기를 이용)

7. npm run setup 을 하면 설치와 배포까지 완료한다.



'Develop' 카테고리의 다른 글

mac 에서 logcat  (0) 2018.02.22
vscode 지금업데이트 안됨  (0) 2017.09.18
xCode Build error GoogleSignIn/GIDSignIn.h file not found  (0) 2017.05.30
unity3d black screen  (0) 2017.03.22
typescript rest arguments 전달 방법  (0) 2017.02.22

유니티에서 play-games-plugin-for-unity를 사용.

ios 에서는 사용하지 않기 위해 NO_GPGS flag 사용.

ios 빌드시 "GoogleSignIn/GIDSignIn.h file not found" 에러 발생


해결 방법은

xcode -> project build settings 

           -> other linker flags

           -> $(inherited) 삭제

           -> $(OTHER_LDFLAGS) 추가


어찌 하다보니 되긴 하는데 이렇게 해서 꼭 잘 될거라는 보장은 없음

'Develop' 카테고리의 다른 글

vscode 지금업데이트 안됨  (0) 2017.09.18
aws lambda express.js 세팅기  (0) 2017.08.23
unity3d black screen  (0) 2017.03.22
typescript rest arguments 전달 방법  (0) 2017.02.22
object c++ 문자열 쪼개기, url에서 데이터 추출  (0) 2017.02.20

splash screen 이후 한장짜리 scene은 잘 나오는데

그 다음 scene이 검은 색으로 표현이 된다.

하지만 ui와 모든 터치가 동작한다.


검색을 해보던 중 비어있는 scene일때 그런 현상이 발생할 수 있다는 글을 봄.

일단 카메라를 설치했고,

다른것들과 마찬가지로  clear flags를 don't clear로 했는데 안됨.

skybox로 설정하니 잘됨.

다른 flag는 사용해보지 않음.



# 결론

 빈 scene에서 addtive로 신을 추가 해서 사용하는 경우

 검은 화면만 표시 될 수 있다.

 카메라를 넣고, clear flags 는 Don't Clear 로 설정하지 마라.


console.log()는 아래와 같이 선언되어 있다.


interface Console {

    Console: typeof NodeJS.Console;

    assert(value: any, message?: string, ...optionalParams: any[]): void;

    dir(obj: any, options?: {showHidden?: boolean, depth?: number, colors?: boolean}): void;

    error(message?: any, ...optionalParams: any[]): void;

    info(message?: any, ...optionalParams: any[]): void;

    log(message?: any, ...optionalParams: any[]): void;

    time(label: string): void;

    timeEnd(label: string): void;

    trace(message?: any, ...optionalParams: any[]): void;

    warn(message?: any, ...optionalParams: any[]): void;

}


이걸 랩핑 하려면


function log(level: Level, message?: any, ...optionalParams: any[]) {

    if (config.log.level <= level) {

        console.log(message, ...optionalParams);

    }

}


export function debug(message?: any, ...optionalParams: any[]) {

    log(Level.Debug, message, ...optionalParams);

}


위와 같이 전달하면 잘 동작 한다.

'Develop' 카테고리의 다른 글

xCode Build error GoogleSignIn/GIDSignIn.h file not found  (0) 2017.05.30
unity3d black screen  (0) 2017.03.22
object c++ 문자열 쪼개기, url에서 데이터 추출  (0) 2017.02.20
nodegit crash  (0) 2017.02.03
git 일부 체크아웃  (0) 2017.01.19

#object c++을 하나도 모르기 때문에 하나씩 공부하면서 작업 진행 중.


url에 실려온 데이터를 파싱 해보자


#import <Foundation/Foundation.h>


int main(int argc, const char * argv[]) {

    @autoreleasepool {

        // insert code here...

        NSLog(@"Hello, World!");

        

        NSString *urlString = @"http://localhost:18080/data?key=123&map=we34";

        

        NSURL *url = [NSURL URLWithString:urlString];

        

        NSLog(@"%@", [url path]);

        NSLog(@"%@", [url query]);

        NSLog(@"%@", [url parameterString]);

        NSLog(@"%@", [[url query] componentsSeparatedByString:@"="][1]);

        

        // 문자열 나누기

        NSArray *words = [[url query] componentsSeparatedByCharactersInSet:

                          [NSCharacterSet characterSetWithCharactersInString:@"=&"]];

        

        NSString *key = nil;

        

        for(int i=0; i<[words count]; i+=2)

        {

            NSLog(@"words : %@", words[i]);

            if([words[i] isEqualToString:@"key"])

            {

                key = words[i+1];

            }

        }

        

        if(key != nil)

        {

            NSLog(@"result : %@", key);

        }

    }

    return 0;

}



맵을 써서 탁탁 정리 해도 되겠으나 당장 필요 없으니 패스


'Develop' 카테고리의 다른 글

unity3d black screen  (0) 2017.03.22
typescript rest arguments 전달 방법  (0) 2017.02.22
nodegit crash  (0) 2017.02.03
git 일부 체크아웃  (0) 2017.01.19
unity android app keystore  (0) 2017.01.12

nodejs에서 nodegit을 이용해 개발을 하고 있었다.


open()

commit()

pull()

push()

순서로 하려고 하는데 계속 crash가 난다.

더블 프리 에러가 libgit2 에서 나는데 이유를 알수 없다.


이리저리 하다보니 credential을 libgit2 내부에서 메모리 해제 하는듯 하다.

push() 전에 credential을 새로 만들어서 넣어주니 문제가 해결 되었다.



요약 : credential은 일회용

'Develop' 카테고리의 다른 글

typescript rest arguments 전달 방법  (0) 2017.02.22
object c++ 문자열 쪼개기, url에서 데이터 추출  (0) 2017.02.20
git 일부 체크아웃  (0) 2017.01.19
unity android app keystore  (0) 2017.01.12
mac, linux 파일 재귀 삭제  (0) 2017.01.10

+ Recent posts