Skip to content

Instantly share code, notes, and snippets.

@jaimeperez
Created August 17, 2017 12:36
Show Gist options
  • Select an option

  • Save jaimeperez/ece28cd1f980c58dcba4b250ea52a8d1 to your computer and use it in GitHub Desktop.

Select an option

Save jaimeperez/ece28cd1f980c58dcba4b250ea52a8d1 to your computer and use it in GitHub Desktop.
A script to encrypt two-factor authenticator secrets for Feide
<?php
include("vendor/autoload.php");
// JSON-encode the Authenticator secret
$plaintext = array("secret" => "<AUTHENTICATOR_SECRET");
// initialize JWE object
$jwe = new JOSE_JWE(json_encode($plaintext));
// encrypt with Feide's key and proper algorithms
$jwe->encrypt(
'<FEIDE_AUTHENTICATOR_PUBLIC_KEY>',
'RSA-OAEP',
'A128CBC-HS256'
);
// print the result
echo $jwe->toString();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment