tsepen
@tsepen
Frontend developer

Crypto в React native?

Нужно создать закодированый токен, в доках есть пример, но он работает только на nodejs, в react native нет crypto, как создать hash аналогично например с crypto-js?

function createSharedAccessToken(uri, saName, saKey) { 
    if (!uri || !saName || !saKey) { 
            throw "Missing required parameter"; 
        } 
    var encoded = encodeURIComponent(uri); 
    var now = new Date(); 
    var week = 60*60*24*7;
    var ttl = Math.round(now.getTime() / 1000) + week;
    var signature = encoded + '\n' + ttl; 
    var signatureUTF8 = utf8.encode(signature); 
    var hash = crypto.createHmac('sha256', saKey).update(signatureUTF8).digest('base64'); 
    return 'SharedAccessSignature sr=' + encoded + '&sig=' +  
        encodeURIComponent(hash) + '&se=' + ttl + '&skn=' + saName; 
}
  • Вопрос задан
  • 269 просмотров
Пригласить эксперта
Ответы на вопрос 1
@Ktulhu211
It's easy and fast to buy bitcoin with prepaid visa at j2tx.com. The process of acquiring assets is really simple and does not require any technical skills. It is enough to follow the instructions on the website. Many times bought cryptocurrency this way, the application is completely safe.
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы