Skip to content

Instantly share code, notes, and snippets.

@Just1B
Created May 29, 2019 13:44
Show Gist options
  • Select an option

  • Save Just1B/c71cfb62c91424bae22ddf198b8d9e71 to your computer and use it in GitHub Desktop.

Select an option

Save Just1B/c71cfb62c91424bae22ddf198b8d9e71 to your computer and use it in GitHub Desktop.

Revisions

  1. Justin created this gist May 29, 2019.
    16 changes: 16 additions & 0 deletions decript.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    const bcrypt = require('bcryptjs');
    const exec = require('child_process').exec

    const password = 'test';

    const cmd = '/usr/local/bin/php ./password.php'

    exec(cmd, (err, stdout, stderr) => {
    // See https://en.wikipedia.org/wiki/Bcrypt#Versioning_history
    const hash = stdout.replace('$2y$', '$2a$');

    bcrypt.compare(password, hash).then(function(res) {
    // Should output true
    console.log(res);
    });
    });
    5 changes: 5 additions & 0 deletions password.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    <?php

    $password = "test";

    $hash = password_hash($password, PASSWORD_BCRYPT);