2017-11-27 1 views

답변

1

에서 발견 NodeJS에서 문자열을 16 진수로 변환하려면 Buffer을 사용하십시오.

Buffer.from('hello world', 'utf8').toString('hex'); 
1

당신은 다음과 같은 기능을 사용할 수 있습니다 :

function stringToHex(str) { 

    //converting string into buffer 
    let bufStr = Buffer.from(str, 'utf8'); 

    //with buffer, you can convert it into hex with following code 
    bufStr.toString('hex'); 

    } 

stringToHex('some string here'); 
관련 문제