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.createEncryptionCipher(keyIv, mode);
      cipher.start(keyIv);
      cipher.update(forge.util.createBuffer(data));
      cipher.finish();
      if (encoder === 'url') {
        return base64url(cipher.output.data);
      }
      return forge.util.encode64(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.createEncryptionCipher(keyIv, mode);
      cipher.start(keyIv);
      cipher.update(forge.util.createBuffer(data));
      cipher.finish();
      if (encoder === 'url') {
        return base64url(cipher.output.data);
      }
      return forge.util.encode64(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 . createEncryptionCipher ( keyIv , mode ) ; cipher . start ( keyIv ) ; cipher . update ( forge . util . createBuffer ( data ) ) ; cipher . finish ( ) ; if ( encoder === 'url' ) { return base64url ( cipher . output . data ) ; } return forge . util . encode64 ( cipher . output . data ) ; }
Encrypt data using AES cipher
@param {String} data The data to encrypt
@param {Bytes} secret The secret to use in encryption
@param {String} [encoder = 'base64'] base64 or url final encoding
@param {String} [mode = 'CTR'] The mode to use in encryption. 'CBC', 'CFB', 'OFB', 'CTR' are allowed modes.
@return {String} The AES encryption result in Base64
Encrypt data using AES cipher