Uploaded image for project: 'Couchbase Server'
  1. Couchbase Server
  2. MB-50134

HASHBYTES function returns hash including quotes

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • 7.1.0
    • 7.1.0
    • query
    • None
    • 7.1.0-1906
    • Untriaged
    • 1
    • Unknown

    Description

      Looks like hashbytes is including quotes when computing,

      For example, I would expect "Hello World" sha256 hash to be: a591a6d40bf420404a011733cfb7b190d62c65bf0bcda32b57b277d9ad9f146e

      >>> hashlib.sha256(b'Hello World').hexdigest()
      'a591a6d40bf420404a011733cfb7b190d62c65bf0bcda32b57b277d9ad9f146e'
       
      # echo -n 'Hello World' | openssl sha256
      (stdin)= a591a6d40bf420404a011733cfb7b190d62c65bf0bcda32b57b277d9ad9f146e 

      but it returns diff hash: 07cf55095ef805a89c07bf3d4764b07352a8f4b2cc3df166e89d2193131536bd

      cbq> select hashbytes('Hello World', {"algorithm":"sha256"});
      {
          "requestID": "789f113c-9fc0-43e8-9f0c-c441c3825ce7",
          "signature": {
              "$1": "string"
          },
          "results": [
          {
              "$1": "07cf55095ef805a89c07bf3d4764b07352a8f4b2cc3df166e89d2193131536bd"
          }
      

      After closer look it seems hash above is for '"Hello World"' as shown below:

      >>> hashlib.sha256(b'"Hello World"').hexdigest()
      '07cf55095ef805a89c07bf3d4764b07352a8f4b2cc3df166e89d2193131536bd'
       

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              pierre.regazzoni Pierre Regazzoni
              pierre.regazzoni Pierre Regazzoni
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes

                  PagerDuty