Skip to main content
added 186 characters in body
Source Link
user12572
  • 436
  • 2
  • 10

Try changing

IntegerString[Hash[StringJoin[opad,ExportString[IntegerDigits[Hash[StringJoin[ipad, message], method], 256],"Binary"]],method],16]

to

Developer`EncodeBase64[
 FromCharacterCode[
  IntegerDigits[
   Hash[
    StringJoin[
     opad,
     ExportString[
      IntegerDigits[
        Hash[
        StringJoin[ipad, message],
        "SHA512"
        ],
       256
       ],
      "Binary"
      ]
     ],
    "SHA512"
    ],
   256
   ]
  ]
 ]

This returns a signature that is Base64 encoded. It's what my API required

Also, I would consider changing all your ExportString[#,{"Base64","String"}] to Developer`EncodeBase64[#]. The ExportString function looks like it adds some formatting to the output.

Try changing

IntegerString[Hash[StringJoin[opad,ExportString[IntegerDigits[Hash[StringJoin[ipad, message], method], 256],"Binary"]],method],16]

to

Developer`EncodeBase64[
 FromCharacterCode[
  IntegerDigits[
   Hash[
    StringJoin[
     opad,
     ExportString[
      IntegerDigits[
        Hash[
        StringJoin[ipad, message],
        "SHA512"
        ],
       256
       ],
      "Binary"
      ]
     ],
    "SHA512"
    ],
   256
   ]
  ]
 ]

This returns a signature that is Base64 encoded. It's what my API required

Try changing

IntegerString[Hash[StringJoin[opad,ExportString[IntegerDigits[Hash[StringJoin[ipad, message], method], 256],"Binary"]],method],16]

to

Developer`EncodeBase64[
 FromCharacterCode[
  IntegerDigits[
   Hash[
    StringJoin[
     opad,
     ExportString[
      IntegerDigits[
        Hash[
        StringJoin[ipad, message],
        "SHA512"
        ],
       256
       ],
      "Binary"
      ]
     ],
    "SHA512"
    ],
   256
   ]
  ]
 ]

This returns a signature that is Base64 encoded. It's what my API required

Also, I would consider changing all your ExportString[#,{"Base64","String"}] to Developer`EncodeBase64[#]. The ExportString function looks like it adds some formatting to the output.

Source Link
user12572
  • 436
  • 2
  • 10

Try changing

IntegerString[Hash[StringJoin[opad,ExportString[IntegerDigits[Hash[StringJoin[ipad, message], method], 256],"Binary"]],method],16]

to

Developer`EncodeBase64[
 FromCharacterCode[
  IntegerDigits[
   Hash[
    StringJoin[
     opad,
     ExportString[
      IntegerDigits[
        Hash[
        StringJoin[ipad, message],
        "SHA512"
        ],
       256
       ],
      "Binary"
      ]
     ],
    "SHA512"
    ],
   256
   ]
  ]
 ]

This returns a signature that is Base64 encoded. It's what my API required