build/authorify.js
function (data, secret, encoder, mode) {
      // mode = CBC, CFB, OFB, CTR
      mode = mode || MODE;
      var keyIv = this.getBytesFromSecret(secret);
      var cipher = forge.aes.createDecryptionCipher(keyIv, mode);
      cipher.start(keyIv);
      var decoded;
      if (encoder === 'url') {
        decoded = base64url.decode(data);
      } else {
        decoded = forge.util.decode64(data);
      }
      cipher.update(forge.util.createBuffer(decoded));
      cipher.finish();
      return cipher.output.data;
    }
function (data, secret, encoder, mode) {
      // mode = CBC, CFB, OFB, CTR
      mode = mode || MODE;
      var keyIv = this.getBytesFromSecret(secret);
      var cipher = forge.aes.createDecryptionCipher(keyIv, mode);
      cipher.start(keyIv);
      var decoded;
      if (encoder === 'url') {
        decoded = base64url.decode(data);
      } else {
        decoded = forge.util.decode64(data);
      }
      cipher.update(forge.util.createBuffer(decoded));
      cipher.finish();
      return cipher.output.data;
    }
function ( data , secret , encoder , mode ) { // mode = CBC, CFB, OFB, CTR mode = mode || MODE ; var keyIv = this . getBytesFromSecret ( secret ) ; var cipher = forge . aes . createDecryptionCipher ( keyIv , mode ) ; cipher . start ( keyIv ) ; var decoded ; if ( encoder === 'url' ) { decoded = base64url . decode ( data ) ; } else { decoded = forge . util . decode64 ( data ) ; } cipher . update ( forge . util . createBuffer ( decoded ) ) ; cipher . finish ( ) ; return cipher . output . data ; }
Decrypt AES encrypted data
@param {String} data The data to decrypt
@param {String} secret The secret to use in decryption in Base64 format
@param {String} [encoder = 'base64'] base64 or url encoding
@param {String} [mode='CTR'] The mode to use in decryption. 'CBC', 'CFB', 'OFB', 'CTR' are allowed modes.
@return {String} The decrypted data
Decrypt AES encrypted data