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 6109181
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:22:34+00:00 2026-05-23T14:22:34+00:00

i have this pseudo code and i would like to convert it into working

  • 0

i have this pseudo code and i would like to convert it into working code:

string constructSignature(string timestamp, string UID, string secretKey) {  
  baseString = timestamp + "_" + UID;                                  // Construct a "base string" for signing  
  binaryBaseString = ConvertUTF8ToBytes(baseString);    // Convert the base string into a binary array  
  binaryKey = ConvertFromBase64ToBytes(secretKey);     // Convert secretKey from BASE64 to a binary array  
  binarySignature = hmacsha1(binaryKey, baseString);      // Use the HMAC-SHA1 algorithm to calculate the signature  
  signature = ConvertToBase64(binarySignature);              // Convert the signature to a BASE64  
  return signature;  
} 

any idea?
thanks

  • 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-23T14:22:34+00:00Added an answer on May 23, 2026 at 2:22 pm

    Some ideas:

    • Don’t calculate BinaryBaseString, given that you never use it
    • Don’t refer to UTF8 for no reason at all — strings in JavaScript are Unicode, which is only distantly connected to UTF.
    • Don’t put implementation details in your pseudocode — especially ones you don’t actually need (like assuming the secret key should be in “bytes”, whatever that means, when in fact, the standard library takes and returns strings).
    • Don’t write comments that just restate what the code is doing.

    Which leaves us with:

    var constructSignature = function(timestamp, UID, secretKey) {  
      return Crypto.HMAC(Crypto.SHA1, timestamp + "_" + UID, secretKey,
                         { asString: true }); 
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi I have below pseudo code with throws an exception like this throw new
I have this pseudo-code in java: bytes[] hash = MD5.hash(example); String hexString = toHexString(hash);
This is going to be a long post. I would like to have suggestions
Bit of a strange one this. Please forgive the semi-pseudo code below. I have
I have a statement I want to express, that in C pseudo-code would look
Does anyone know how to do this and what the pseudo code would look
Running ipconfig /all shows a Teredo Tunneling Pseudo-Interface. What is that? Does this have
This is something I've pseudo-solved many times and have never quite found a solution
I have this code in jQuery, that I want to reimplement with the prototype
I have this gigantic ugly string: J0000000: Transaction A0001401 started on 8/22/2008 9:49:29 AM

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.