Skip to content

Instantly share code, notes, and snippets.

@samverneck
Last active December 17, 2016 22:51
Show Gist options
  • Select an option

  • Save samverneck/d79fa327d196bb672253cfd1fa6f5090 to your computer and use it in GitHub Desktop.

Select an option

Save samverneck/d79fa327d196bb672253cfd1fa6f5090 to your computer and use it in GitHub Desktop.
var crypto = require('crypto');
crypto.randomBytes(tamanho, function (erro, resultado ) {
if (erro) {throw erro;}
console.log('Uma string aleatória de %d bytes: %s', resultado .length, resultado);
});
// ========
// crypto node.js
const crypto = require('crypto');
const secret = 'abcdefg';
const hash = crypto.createHmac('sha256', secret)
// mensagem aqui em baixo
.update('Tente descobrir se for capaz seu')
.digest('hex');
console.log(hash);
// imprimindo
// carregando...
//aqui está sua mensagem
// cd3046921599d7e5aa6f61bbe6560bb748cc3c4a67d8d11816a66d6e45e0663e
const crypto = require('crypto');
const secret = 'abcdefg';
const hash = crypto.createHmac('md5', secret)
.update('Tente descobrir se for capaz seu')
.digest('hex');
console.log(hash);
// imprimindo
// carregando...
//aqui está sua mensagem
// 4334d64e25c0934e6f36de1b3c638e03
@samverneck
Copy link
Copy Markdown
Author

samverneck commented Dec 16, 2016

crypto node.js utilizei o node,js.
haha

para estudos: https://nodejs.org/docs/v7.1.0/api/crypto.html#crypto_crypto

@samverneck
Copy link
Copy Markdown
Author

teve up no codigo agora com MD5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment