[컴][윈도우] 태스크바의 Windows Ink 끄기

Windows Ink turn off / taskbar //


Windows Ink 를 taskbar 에서 안보이게 하기

Windows 10 Anniversary Update 가 설치되면서 Windows Ink 가 task bar 에 보이기 시작했다. 개인적으로 이런것을 싫어해서 삭제를 했다.

taskbar 에서 안보이게 하기

  1. taskbar 에서 마우스 오른쪽 버튼
  2. Windows Ink 작업 영역 단추 표시 끄기

기능 사용 안하기

  1. gpedit.msc
  2. 컴퓨터 구성(Computer Configuration.) > 관리 템플릿 > Windows Ink Workspace.
  3. Windows Ink 작업 영역 허용 의 상태를 '사용 안 함' 으로 변경
  4. restart

References

  1. How to disable Windows Ink Workspace on Windows 10 | Windows Central

[컴][nodejs] AdonisJS 설치

adonis debugger setting / 디버거 세팅


AdonisJS

일단 이녀석은 php 의 framework Laravel 의 구조를 그대로 가져왔다 .그래서 Laravel 을 사용해 봤다면 이해가 어렵지 않아 보인다.

AdonisJs CLI 설치

이녀석을 설치하면, 추후에 작업을 하는것이 좀 더 수월하다. 반복적인 작업들(파일생성등) 을 할 때 용이한 듯 하다.

npm i @adonisjs/cli

project 생성

일단 project 를 생성해 보자. 아래처럼 하면 myproj 라는 project 가 하나 생성된다.
adonis.cmd new myproj

.env

일단 설치를 하고 나면, .env 설정을 해줘야 하는데, key:generate 를 해주면 자동으로 생성된다.

cd myproj
adonis.cmd key:generate

run server

adonis.cmd serve --dev


unit test 

아래처럼 실행하면 된다.
c:\project_root> adonis test 
c:\project_root> adonis test --files invest-limit.spec.js,auth.spec.js 



VSCode, typescript


vscode debugger 세팅하기

launch.js

먼저 vscode 내의 terminal 에서 adonis serve --dev 로 서버를 실행한다. 그리고 나서 vscode를 열고, debugger 를 실행하면 된다.(attach)

또는 아래 'launch' 를 이용해서 바로 실행해도 된다.

launch.js 는 아래처럼 설정하면 된다.
{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        
        {
            "type": "node",
            "request": "attach",
            "name": "Attach by Process ID",
            "processId": "${command:PickProcess}"
        },
        {
            "type": "node",
            "request": "launch",
            "name": "Launch Program",
            "program": "${workspaceFolder}/app.js",
            "args": [
                "--dev",
            ]
        },
        {
            "type": "node",
            "request": "launch",
            "name": "Unit test Launch Program",
            "program": "${workspaceFolder}/test_ace.js",
            "args": [
                "test",
                "-f",
                "${fileBasename}"
            ],
            "internalConsoleOptions": "openOnSessionStart",
        },
    ]
}

실행

실행을 하면 attach 할 process 를 선택하라고 나온다. 이때 adonis server --dev 외에 다른 프로세스를 선택한다.

unit test 실행

unit test 를 하면서 관련해서 debugger mode 를 사용하려면, 위처럼 하면 된다.

test_ace.js
ace file 을 그대로 실행할 수 없다. .js file 이 필요해서 아래처럼 .js file 을 만들면 된다.

'use strict'

require('./ace');

cmd 에서 바로 unittest 실행

node test_ace.js test -f myclass.spec.js



다른 방법

서버 실행

node --inspect server.js

debugger 붙이기(attach)

기본적으로 node 가 9229 로 debugger port를 연다.
{
    "type": "node",
    "request": "attach",
    "name": "Attach to localhost",
    "address": "localhost",
    "port": 9229,
    "localRoot": "${workspaceFolder}",
    "remoteRoot": "${workspaceFolder}"
},

See Also

  1. AdoniJS at Start up, 2019-02-07
  2. [컴][웹] Adonijs Unittest 사용시 Tips

References

  1. Installation Adonis JS 4.1



[컴] Windows 용 Docker 설치

docker for windows


Windows 에서 docker 설치

Installation

위 경로에서 download 를 하면 된다.

prerequisite 전제조건

  • Microsoft Hyper-V 가 실행돼야 한다.: The Docker for Windows installer 가 enable 해준다.
  • 옛날 windows 의 docker toolbox는 VM (Virtual Box)을 사용했었는데, 이제는 VM 을 사용하지 않는다. : Docker for Mac vs. Docker Toolbox  를 읽어보자.

System Requirements

아래 조건을 만족해야 한다. 만족하지 않아도 docker toolbox 를 사용할 수는 있다.

  • Windows 10 64bit: Pro, Enterprise or Education (1607 Anniversary Update, Build 14393 or later).
  • BIOS 에서 Virtualization 을 켜야 한다.(기본적으로 켜져있다.)
  • CPU SLAT-capable feature.
  • At least 4GB of RAM.

설치마법사







설치 확인

service 를 실행하면 아래처럼 process 를 확인할 수 있다.


그리고 cmd 를 열어서 아래처럼 "docker run helloworld"를 쳐보면 된다.


Image Path

Settings > Advanced > Disk Image Location 에 가면 docker image 의 path 를 확인할 수 있다.

See Also

  1. 쿠...sal: [컴] Docker 설치 후 VMbox 가 안되는 경우

References

  1. Install Docker for Windows | Docker Documentation


[컴] MIT open courses

mooc / mit open courses / mit 오픈 코스들 / 컴퓨터 사이언스 코스 / 동영상 강의

MIT Open courses














See Also

  1. Stanford C programming
  2. 500 Free Computer Science Courses from the World’s Top CS Universities
  3. 150+ Stanford On-Campus Computer Science Courses Available Online : 스탠포드 대학 강의들을 주제별로 , 코스별로 묶어놨다.
  4. 쿠...sal: [컴][자료] Computer Science 관련 학습 자료

References

  1. MIT OCW : OCW Course Index | MIT OpenCourseWare | Free Online Course Materials

[컴] from php openssl to pycrypto (CTR mode, CBC mode)

php openssal to java abs cbc encrypt /

CTR mode from php openssl to pycrypto

php openssl ctr mode to python pycripto

To convert the php AES.CTR encryption to python AES.CTR encryption

php openssl code

$cipher = 'aes-256-ctr';

if (in_array($cipher, openssl_get_cipher_methods()))
{
    // Usually the below code is used for $iv
    // $ivlen = openssl_cipher_iv_length($cipher);
    // $iv = openssl_random_pseudo_bytes($ivlen);

    $key = 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA';

    // to start Counter from 1
    $iv0 = [00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,01];
    $iv = implode(array_map("chr", $iv0));

  
    $plaintext = 'test.test';
    $ciphertext = openssl_encrypt($plaintext, $cipher, $key, OPENSSL_RAW_DATA, $iv);
    $encodedCT = base64_encode($ciphertext); // $encodedCT => 'izQmJQ8nkPMP'
    
    //store $cipher, $iv, and $tag for decryption later    
    $original_plaintext = openssl_decrypt($encodedCT, $cipher, $key, 0, $iv);
    $original_plaintext2 = openssl_decrypt($ciphertext , $cipher, $key, OPENSSL_RAW_DATA, $iv);
}

python pycripto code


from Crypto.Cipher import AES
from Crypto.Util import Counter

import base64


def encrypt_token_ctr(data):
    key = b'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
    iv = 1

    # to convert string 'iv' to int value to use for initial_value
    # iv = b'AAAAAAAAAAAAAAAA'
    # import binascii
    # hexval = binascii.hexlify(iv)
    # iv = int(hexval, 16)

    aes = AES.new(key=key, 
        mode=AES.MODE_CTR, 
        counter=Counter.new(128, initial_value=iv)
    )

    return aes.encrypt(data.encode('utf8'))

def decrypt_token_ctr(data):
    key = b'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
    iv = 1

    aes = AES.new(key=key, 
        mode=AES.MODE_CTR, 
        counter=Counter.new(128, initial_value=iv)
    )

    return aes.decrypt(data)

print('Python encrypt: ' + str(base64.b64encode(encrypt_token_ctr('test.test'))) )
print('Python encrypt: ' + str(decrypt_token_ctr(base64.b64decode('izQmJQ8nkPMP'))) )


>> Python encrypt2: b'mzwsKw88h+c='
>> Python decrypt2: b'test.test'



AES CBC mode

php code


class AES
{
    var $key = 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA';
    var $iv = 'AAAAAAAAAAAAAAAA';
 
    function encryptToken($data)
    {
        // Mcrypt library has been DEPRECATED since PHP 7.1, use openssl:
        // return openssl_encrypt($data, 'aes-256-cbc', $this->key, OPENSSL_RAW_DATA, $this->iv);

        $message_padded = $data;
        if (strlen($message_padded) % 8) {
            $message_padded = str_pad($message_padded,
                strlen($message_padded) + 8 - strlen($message_padded) % 8, "\0");
        }

        // $padding = 16 - (strlen($data) % 16);
        // $data .= str_repeat(chr($padding), $padding);
        return openssl_encrypt($message_padded, 'aes-256-cbc', $this->key, OPENSSL_RAW_DATA, $this->iv);
    }
 
    function decryptToken($data)
    {
        // Mcrypt library has been DEPRECATED since PHP 7.1, use openssl:
        // return openssl_decrypt(base64_decode($data), 'aes-256-cbc', $this->key, OPENSSL_RAW_DATA, $this->iv);
        $data = openssl_decrypt(base64_decode($data), 'aes-256-cbc', $this->key, OPENSSL_RAW_DATA, $this->iv);
        $padding = ord($data[strlen($data) - 1]);
        return substr($data, 0, -$padding);
    }
}

python code


from Crypto.Cipher import AES

def _pad(s): return (s + (AES.block_size - len(s) % AES.block_size) * chr(AES.block_size - len(s) % AES.block_size)).encode('utf8')

def _cipher():
    key = b'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
    iv = b'AAAAAAAAAAAAAAAA'
    return AES.new(key=key, mode=AES.MODE_CBC, IV=iv)


def encrypt_token(data):
    return _cipher().encrypt(_pad(data))

if __name__ == '__main__':
    print('Python encrypt: ' + str(base64.b64encode(encrypt_token('test.test'))) )
    print('Python decrypt: ' + str(decrypt_token(base64.b64decode('1pRLMUTqMCdBM4EyNyBTuQ=='))) )



See Also

  1. Encrypt and decrypt content with Nodejs · Christoph Hartmann
  2. AES/CBC/PKCS5Padding encrypt/decrypt PHP and JAVA example classes : java code <--> php code