packages/crypto/lib/index.js
function ensureBuffer (message) {
  if (Buffer.isBuffer(message)) return message

  switch (typeof message) {
    case 'string':
      message = isHex(message) ? Buffer.from(message, 'hex') : Buffer.from(message)
      break
    case 'object':
      message = Buffer.from(JSON.stringify(message))
      break
  }

  return Buffer.isBuffer(message) ? message : false
}
function ensureBuffer (message) {
  if (Buffer.isBuffer(message)) return message

  switch (typeof message) {
    case 'string':
      message = isHex(message) ? Buffer.from(message, 'hex') : Buffer.from(message)
      break
    case 'object':
      message = Buffer.from(JSON.stringify(message))
      break
  }

  return Buffer.isBuffer(message) ? message : false
}
function ensureBuffer ( message ) { if ( Buffer . isBuffer ( message ) ) return message switch ( typeof message ) { case 'string' : message = isHex ( message ) ? Buffer . from ( message , 'hex' ) : Buffer . from ( message ) break case 'object' : message = Buffer . from ( JSON . stringify ( message ) ) break } return Buffer . isBuffer ( message ) ? message : false }
Ensure message is in buffer format.
@param {string} message - any string.
@return {string} Returns Buffer of string.
Ensure message is in buffer format .