src/crypto_browser.js
function(ciphertext, key, iv, encoding) {
      var binary, bytes, hex;
      if (encoding == null) {
        encoding = "buffer";
      }
      iv = this.toBuffer(iv);
      key = this.toBuffer(key);
      ciphertext = this.toBuffer(ciphertext);
      binary = Gibberish.rawDecrypt(ciphertext, key, iv, true);
      hex = this.bin2hex(binary);
      if (encoding === 'hex') {
        return hex;
      }
      bytes = Gibberish.h2a(hex);
      if (encoding === 'base64') {
        return Gibberish.Base64.encode(bytes);
      }
      if (encoding === "buffer") {
        return bytes;
      } else {
        throw new Error("Encoding now supported");
      }
    }
function(ciphertext, key, iv, encoding) {
      var binary, bytes, hex;
      if (encoding == null) {
        encoding = "buffer";
      }
      iv = this.toBuffer(iv);
      key = this.toBuffer(key);
      ciphertext = this.toBuffer(ciphertext);
      binary = Gibberish.rawDecrypt(ciphertext, key, iv, true);
      hex = this.bin2hex(binary);
      if (encoding === 'hex') {
        return hex;
      }
      bytes = Gibberish.h2a(hex);
      if (encoding === 'base64') {
        return Gibberish.Base64.encode(bytes);
      }
      if (encoding === "buffer") {
        return bytes;
      } else {
        throw new Error("Encoding now supported");
      }
    }
function ( ciphertext , key , iv , encoding ) { var binary , bytes , hex ; if ( encoding == null ) { encoding = "buffer" ; } iv = this . toBuffer ( iv ) ; key = this . toBuffer ( key ) ; ciphertext = this . toBuffer ( ciphertext ) ; binary = Gibberish . rawDecrypt ( ciphertext , key , iv , true ) ; hex = this . bin2hex ( binary ) ; if ( encoding === 'hex' ) { return hex ; } bytes = Gibberish . h2a ( hex ) ; if ( encoding === 'base64' ) { return Gibberish . Base64 . encode ( bytes ) ; } if ( encoding === "buffer" ) { return bytes ; } else { throw new Error ( "Encoding now supported" ) ; } }
Decipher encrypted data.
@param {String|Buffer} ciphertext The data to decipher. Must be a multiple of the blocksize.
@param {String|Buffer} key The key to decipher the data with.
@param {String|Buffer} iv The initialization vector to use.
@param {String} [encoding=buffer] The format to return the decrypted contents as.
@return {Buffer|String} The decrypted contents.
Decipher encrypted data .