Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 844381
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T06:16:37+00:00 2026-05-15T06:16:37+00:00

So i am trying to call this function in my javascript but it gives

  • 0

So i am trying to call this function in my javascript but it gives me the error of “Microsoft JScript runtime error Object doesn’t support this property or method” and i cant figure out why. It is occuring when trying to call hmacObj.getHMAC. This is from the jsSHA website: http://jssha.sourceforge.net/ to use the hmac-sha1 algorithm encryption. Thank you!

hmacObj = new jsSHA(signature_base_string,"HEX");

signature = hmacObj.getHMAC(signature_key,"HEX","SHA-1","HEX");

Above this i have copied the code from sha.js

snippet:

function jsSHA(srcString, inputFormat) {

 /*
  * Configurable variables. Defaults typically work
  */
 jsSHA.charSize = 8; // Number of Bits Per character (8 for ASCII, 16 for Unicode)
 jsSHA.b64pad  = ""; // base-64 pad character. "=" for strict RFC compliance
 jsSHA.hexCase = 0; // hex output format. 0 - lowercase; 1 - uppercase

 var sha1 = null;
 var sha224 = null;

The function it is calling (inside of the jsSHA function)

this.getHMAC = function (key, inputFormat, variant, outputFormat) {
        var formatFunc = null;
        var keyToUse = null;
        var blockByteSize = null;
        var blockBitSize = null;
        var keyWithIPad = [];
        var keyWithOPad = [];
        var lastArrayIndex = null;
        var retVal = null;
        var keyBinLen = null;
        var hashBitSize = null;

        // Validate the output format selection
        switch (outputFormat) {
        case "HEX":
            formatFunc = binb2hex;
            break;
        case "B64":
            formatFunc = binb2b64;
            break;
        default:
            return "FORMAT NOT RECOGNIZED";
        }

        // Validate the hash variant selection and set needed variables
        switch (variant) {
        case "SHA-1":
            blockByteSize = 64;
            hashBitSize = 160;
            break;
        case "SHA-224":
            blockByteSize = 64;
            hashBitSize = 224;
            break;
        case "SHA-256":
            blockByteSize = 64;
            hashBitSize = 256;
            break;
        case "SHA-384":
            blockByteSize = 128;
            hashBitSize = 384;
            break;
        case "SHA-512":
            blockByteSize = 128;
            hashBitSize = 512;
            break;
        default:
            return "HASH NOT RECOGNIZED";
        }

        // Validate input format selection
        if ("HEX" === inputFormat) {
            // Nibbles must come in pairs
            if (0 !== (key.length % 2)) {
                return "KEY MUST BE IN BYTE INCREMENTS";
            }
            keyToUse = hex2binb(key);
            keyBinLen = key.length * 4;
        } else if ("ASCII" === inputFormat) {
            keyToUse = str2binb(key);
            keyBinLen = key.length * jsSHA.charSize;
        } else {
            return "UNKNOWN KEY INPUT TYPE";
        }

        // These are used multiple times, calculate and store them
        blockBitSize = blockByteSize * 8;
        lastArrayIndex = (blockByteSize / 4) - 1;

        // Figure out what to do with the key based on its size relative to
        // the hash's block size
        if (blockByteSize < (keyBinLen / 8)) {
            if ("SHA-1" === variant) {
                keyToUse = coreSHA1(keyToUse, keyBinLen);
            } else {
                keyToUse = coreSHA2(keyToUse, keyBinLen, variant);
            }
            // For all variants, the block size is bigger than the output size
            // so there will never be a useful byte at the end of the string
            keyToUse[lastArrayIndex] &= 0xFFFFFF00;
        } else if (blockByteSize > (keyBinLen / 8)) {
            // If the blockByteSize is greater than the key length, there will
            // always be at LEAST one "useless" byte at the end of the string
            keyToUse[lastArrayIndex] &= 0xFFFFFF00;
        }

        // Create ipad and opad
        for (var i = 0; i <= lastArrayIndex; i++) {
            keyWithIPad[i] = keyToUse[i] ^ 0x36363636;
            keyWithOPad[i] = keyToUse[i] ^ 0x5C5C5C5C;
        }

        // Calculate the HMAC
        if ("SHA-1" === variant) {
            retVal = coreSHA1(keyWithIPad.concat(strToHash), blockBitSize + strBinLen);
            retVal = coreSHA1(keyWithOPad.concat(retVal), blockBitSize + hashBitSize);
        } else {
            retVal = coreSHA2(keyWithIPad.concat(strToHash), blockBitSize + strBinLen, variant);
            retVal = coreSHA2(keyWithOPad.concat(retVal), blockBitSize + hashBitSize, variant);
        }

        return (formatFunc(retVal));
    };
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T06:16:38+00:00Added an answer on May 15, 2026 at 6:16 am

    So i discovered that when I was instancing the object it was not creating the actual function within it. With some tweaking i was able to get it to show up and was able to call the function.

    Also noticing that calling Object.getHMAC(String,string,string,string) doesn’t always understand that your string is compatible with its function. Thanks all to those who helped. (John & Sean)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 459k
  • Answers 459k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer This is either a bug or a security "feature" of… May 15, 2026 at 11:30 pm
  • Editorial Team
    Editorial Team added an answer According to the CodeIgniter User guide for the Active Record… May 15, 2026 at 11:30 pm
  • Editorial Team
    Editorial Team added an answer Your :focus rule overrides it. Make another rule that's more… May 15, 2026 at 11:30 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.