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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T04:43:14+00:00 2026-05-20T04:43:14+00:00

I have here the following data for which I have to find the sha1

  • 0

I have here the following data for which I have to find the sha1 digest using openssl.

data:

AwAIAOwIAAABABwAgAIAABYAAAAAAAAAAAAAAHQAAAAAAAAAAAAAAAgAAAAkAAAAQgAAAFQAAABsAAAAhgAAAJgAAACuAAAAwgAAAM4AAADsAAAAAgEAAAwBAAAoAQAARgEAAFgBAACwAQAAtAEAANABAADkAQAA+gEAAAIAaQBkAAAADABsAGEAeQBvAHUAdABfAHcAaQBkAHQAaAAAAA0AbABhAHkAbwB1AHQAXwBoAGUAaQBnAGgAdAAAAAcAZwByAGEAdgBpAHQAeQAAAAoAYgBhAGMAawBnAHIAbwB1AG4AZAAAAAsAbwByAGkAZQBuAHQAYQB0AGkAbwBuAAAABwBwAGEAZABkAGkAbgBnAAAACQB0AGUAeAB0AEMAbwBsAG8AcgAAAAgAdABlAHgAdABTAGkAegBlAAAABAB0AGUAeAB0AAAADQBwAGEAZABkAGkAbgBnAEIAbwB0AHQAbwBtAAAACQBzAGMAYQBsAGUAVAB5AHAAZQAAAAMAcwByAGMAAAAMAHAAYQBkAGQAaQBuAGcAUgBpAGcAaAB0AAAADQBsAGEAeQBvAHUAdABfAHcAZQBpAGcAaAB0AAAABwBhAG4AZAByAG8AaQBkAAAAKgBoAHQAdABwADoALwAvAHMAYwBoAGUAbQBhAHMALgBhAG4AZAByAG8AaQBkAC4AYwBvAG0ALwBhAHAAawAvAHIAZQBzAC8AYQBuAGQAcgBvAGkAZAAAAAAAAAAMAEwAaQBuAGUAYQByAEwAYQB5AG8AdQB0AAAACABUAGUAeAB0AFYAaQBlAHcAAAAJAEkAbQBhAGcAZQBWAGkAZQB3AAAABgBCAHUAdAB0AG8AbgAAAAAAgAEIAEQAAADQAAEB9AABAfUAAQGvAAEB1AABAcQAAQHVAAEBmAABAZUAAQFPAQEB2QABAR0BAQEZAQEB2AABAYEBAQEAARAAGAAAABEAAAD/////DwAAABAAAAACARAAsAAAABEAAAD//////////xIAAAAUABQABwAAAAAAAAAQAAAAAwAAAP////8IAAAREQAAABAAAAAFAAAA/////wgAABABAAAAEAAAAAAAAAD/////CAAAAR0AB38QAAAABAAAAP////8IAAABEQAGfxAAAAAGAAAA/////wgAAAUBEAAAEAAAAAEAAAD/////CAAAEP////8QAAAAAgAAAP////8IAAAQ/////wIBEACcAAAAGgAAAP//////////EwAAABQAFAAGAAAAAAAAABAAAAAIAAAA/////wgAAAUCEgAAEAAAAAcAAAD/////CAAAARAABn8QAAAACgAAAP////8IAAAFARgAABAAAAABAAAA/////wgAABD/////EAAAAAIAAAD/////CAAAEP7///8QAAAACQAAAP////8IAAABRwAIfwMBEAAYAAAAIAAAAP//////////EwAAAAIBEAB0AAAAIgAAAP//////////EgAAABQAFAAEAAAAAAAAABAAAAAFAAAA/////wgAABAAAAAAEAAAAAQAAAD/////CAAAAREABn8QAAAAAQAAAP////8IAAAQ/////xAAAAACAAAA/////wgAABD+////AgEQAIgAAAAoAAAA//////////8UAAAAFAAUAAUAAAAAAAAAEAAAAA0AAAD/////CAAABQEYAAAQAAAAAQAAAP////8IAAAQ/v///xAAAAACAAAA/////wgAABD+////EAAAAAwAAAD/////CAAAAQEAAn8QAAAACwAAAP////8IAAAQBQAAAAMBEAAYAAAALQAAAP//////////FAAAAAIBEAB0AAAALwAAAP//////////EgAAABQAFAAEAAAAAAAAABAAAAAFAAAA/////wgAABABAAAAEAAAAAEAAAD/////CAAABQEAAAAQAAAAAgAAAP////8IAAAQ/v///xAAAAAOAAAA/////wgAAAQAAIA/AgEQAHQAAAA1AAAA//////////8VAAAAFAAUAAQAAAAAAAAAEAAAAAAAAAD/////CAAAASgAB38QAAAAAQAAAP////8IAAAQ/////xAAAAACAAAA/////wgAABD+////EAAAAAkAAAD/////CAAAARUACH8DARAAGAAAADgAAAD//////////xUAAAACARAAdAAAADoAAAD//////////xUAAAAUABQABAAAAAAAAAAQAAAAAAAAAP////8IAAABKgAHfxAAAAABAAAA/////wgAABD/////EAAAAAIAAAD/////CAAAEP7///8QAAAACQAAAP////8IAAABGgAIfwMBEAAYAAAAPQAAAP//////////FQAAAAMBEAAYAAAAPwAAAP//////////EgAAAAIBEAB0AAAAQQAAAP//////////EgAAABQAFAAEAAAAAAAAABAAAAAFAAAA/////wgAABABAAAAEAAAAAEAAAD/////CAAABQEAAAAQAAAAAgAAAP////8IAAAQ/v///xAAAAAOAAAA/////wgAAAQAAIA/AgEQAHQAAABHAAAA//////////8VAAAAFAAUAAQAAAAAAAAAEAAAAAAAAAD/////CAAAASkAB38QAAAAAQAAAP////8IAAAQ/////xAAAAACAAAA/////wgAABD+////EAAAAAkAAAD/////CAAAARYACH8DARAAGAAAAEoAAAD//////////xUAAAACARAAdAAAAEwAAAD//////////xUAAAAUABQABAAAAAAAAAAQAAAAAAAAAP////8IAAABKwAHfxAAAAABAAAA/////wgAABD/////EAAAAAIAAAD/////CAAAEP7///8QAAAACQAAAP////8IAAABGQAIfwMBEAAYAAAATwAAAP//////////FQAAAAMBEAAYAAAAUQAAAP//////////EgAAAAMBEAAYAAAAUwAAAP//////////EgAAAAMBEAAYAAAAVQAAAP//////////EgAAAAEBEAAYAAAAVQAAAP////8PAAAAEAAAABgAAAA9AAAA//////////8fAAAAAgEQAGAAAAA/AAAA//////////8eAAAAFAAUAAMAAAAAAAAAGQAAAAUAAAD/////CAAAEAAAAAAZAAAAAAAAAP////8IAAAQ/v///xkAAAABAAAA/////wgAABD+////AgEQAMQAAABEAAAA//////////8gAAAAFAAUAAgAAAAAAAAAGQAAABIAAAD/////CAAABQIOAAAZAAAAEQAAAP////8IAAARAQAAABkAAAAQAAAA/////wgAAAEGAAZ/GQAAAAIAAAD/////CAAAARIAB38ZAAAAEwAAAP////8IAAAFAQQAABkAAAAAAAAA/////wgAABD+////GQAAAAEAAAD/////CAAAEP7///8ZAAAADwAAAP////8IAAABMwAIfwMBEAAYAAAASwAAAP//////////IAAAAAIBEACIAAAATQAAAP//////////IAAAABQAFAAFAAAAAAAAABkAAAASAAAA/////wgAAAUCDgAAGQAAABAAAAD/////CAAAAQYABn8ZAAAAAgAAAP////8IAAABEwAHfxkAAAAAAAAA/////wgAABD+////GQAAAAEAAAD/////CAAAEP7///8DARAAGAAAAFEAAAD//////////yAAAAADARAAGAAAAFMAAAD//////////x4AAAACARAAYAAAAFUAAAD//////////x4AAAAUABQAAwAAAAAAAAAZAAAABQAAAP////8IAAAQAAAAABkAAAAAAAAA/////wgAABD+////GQAAAAEAAAD/////CAAAEP7///8CARAAxAAAAFoAAAD//////////yAAAAAUABQACAAAAAAAAAAZAAAAEgAAAP////8IAAAFAg4AABkAAAARAAAA/////wgAABEBAAAAGQAAABAAAAD/////CAAAAQYABn8ZAAAAAgAAAP////8IAAABFAAHfxkAAAATAAAA/////wgAAA

The digest as given to me is:
Wk2pJnOErEHsElMw4TMX+rjHsQQ=

But when I use(f1= file where I copied the above data):

base64 -d f1.txt | openssl dgst -sha1 -binary | base64

I get a “base64: invalid input” error and the following digest which seems completely different 🙁

BaRlDid73RYBFMgqveC8G+gFBBU=

Can somebody confirm and explain if there is some mistake??

UPDATED:

Scenario: Client’s binary file is base64 encoded and sent to server. Server decodes this and computes the sha1 digest. Since I have client’s base64 encoded sha1 digest, the server also encodes the digest to base64. Now these two should match. And it doesn’t! I receive all data. I have rechecked it. I shall present part of the code here:

//RCVBUFSIZE = 1024 (defined)
void HandleClient(int clntSocket)
{
char echoBuffer[RCVBUFSIZE] ;        /* Buffer for echo string */
    memset(echoBuffer, 0, RCVBUFSIZE);
    char inBuffer;        /* Buffer for first string */
    char recv_data;
    int recvMsgSize = 0;                    /* Size of received message */
    char replyBuffer[32];
    int bytes_received = 0;
    int rv = 0;
    int connected = clntSocket;
    int len= 0;
    int i = 0;
     EVP_MD_CTX md_ctx;
     const EVP_MD *md;
     unsigned char md_value[EVP_MAX_MD_SIZE];
     unsigned int md_len;
     OpenSSL_add_all_digests();
     md = EVP_get_digestbyname("sha1");
     EVP_MD_CTX_init(&md_ctx);
     EVP_DigestInit_ex(&md_ctx, md, NULL);

    /* Receive message from client */
    while (((bytes_received = recv(connected,&inBuffer,1,0)) > 0) && (inBuffer != '\n')){

    /* Send received string and receive again until end of transmission */
    if (bytes_received  > 0)      /* zero indicates end of transmission */
    {
    printf("Message received from Client is : %c\n", inBuffer);
    char n = inBuffer;
    int indicator =  0;
    int current = 0;
    unsigned long fileLen;

    if(n =='6'){
        if ((recvMsgSize = recv(connected, echoBuffer, RCVBUFSIZE, 0)) < 0)
        DieWithError("recv() failed");
        printf("no. of bytes got : %d\n", recvMsgSize);
        if (recvMsgSize > 0)
        echoBuffer[recvMsgSize] = '\0';
        len= atoi(echoBuffer);
        char *data =NULL;
        printf("length of following message : %d\n", len);
        if(len>0){
    for( i = RCVBUFSIZE; i < (len+RCVBUFSIZE); i=i+RCVBUFSIZE){
                if(i>len)
                recvMsgSize = recv(connected, echoBuffer, (len - (i-RCVBUFSIZE)), 0);
                else
                recvMsgSize = recv(connected, echoBuffer, RCVBUFSIZE, 0);               
                echoBuffer[recvMsgSize] = '\0';
                decode(echoBuffer, recvMsgSize, "file_out");
                data = readFileBuffer("file_out");
                EVP_DigestUpdate(&md_ctx, data, strlen(data));
            }
        }
        len = 0;
        memset(echoBuffer, 0, RCVBUFSIZE);
        recvMsgSize = 0;

    }


    if (n =='5'){
            printf("Update Digest Over- Calculate Final Dgst!!!!! \n");
            n= 0;

            EVP_DigestFinal_ex(&md_ctx, md_value, &md_len); //retrieve digest from ctx unto md_value and #bytes written is copied into   md_len
            EVP_MD_CTX_cleanup(&md_ctx);
            FILE *f;
             f = fopen("file_sha1", "w");
            printf("\n");
            printf("******************************************************\n ");
            printf("Digest is: ");
            for(i = 0; i < md_len; i++){
                if ( f !=NULL){
                    fputc(md_value[i], f);
                    }
            printf("%02x", md_value[i]);
            }
            printf("\n");
            printf("******************************************************\n ");
            fclose(f);
    }
printf("socket closing\n");
    close(connected);    /* Close client socket */
}
}

char *readFileBuffer(char *name)
{
    FILE *file;
    char *buffer = NULL;
    unsigned long fileLen;
    //Open file
    file = fopen(name, "rb");
    if (!file)
    {
        fprintf(stderr, "Unable to open file %s", name);
        return;
    }
    //Get file length
    fseek(file, 0, SEEK_END);
    fileLen=ftell(file);
    printf("file length  = %ld\n", fileLen);
    fseek(file, 0, SEEK_SET);

    //printf("Allocate memory\n");
    buffer=(char *)malloc(fileLen+1);
    printf("length of write buffer = %d\n", strlen(buffer));
    if (!buffer)
    {
        fprintf(stderr, "Memory error!");

    }

    long int n = fread(buffer,1, fileLen,file);
    buffer[n] = '\0';
    printf("Read no. of bytes = %ld into buffer \n", n);
    printf("len of buffer  %d  \n", strlen(buffer));
    if (!buffer)
    {
        fprintf(stderr, "Memory error!");
        fclose(file);
    }
    fclose(file);
    //free(name);
    return buffer;

}

// reads b64 encoded msg (ReadBuffer) and writes to WriiteFile.
void decode(char *ReadBuffer, int Length, char *WriteFile)
{
    char *msg = (char *)malloc(Length);
    memset(msg, 0x00, Length);
    int readbytes = -1;

    printf("buffer write file %s\n", WriteFile);

    // the decode msg is written to this bio
    BIO *fileWrBIO = BIO_new_file(WriteFile, "w");

    BIO *b64 = BIO_new(BIO_f_base64());
    BIO *bio = BIO_new_mem_buf(ReadBuffer, Length);
    bio = BIO_push(b64, bio);
    BIO_set_flags(bio,BIO_FLAGS_BASE64_NO_NL);

    while ((readbytes = BIO_read(bio, msg, Length)) > 0)
    {
    printf("readbytes:  %d\n", readbytes);
       BIO_write(fileWrBIO, msg, readbytes);
       BIO_flush(fileWrBIO);
       memset(msg, 0x00, sizeof(msg));
    }
    free(msg);
    BIO_free_all(bio);
    BIO_free_all(fileWrBIO);
}
  • 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-20T04:43:14+00:00Added an answer on May 20, 2026 at 4:43 am

    Your data is invalid, probably partial. A valid base64 encoded string should have a length multiple of 4. So the different digest output is expected.

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

Sidebar

Related Questions

I have the following code, which compiles but doesn't bring back any data. Here
Lets say we have a table here, populated with the following data: acc_id1 acc_id2
I have a xls file. Which have following data. Now I want to get
I have the following cell which is used for my custom column data type
A working version of this is here: http://est.pagodabox.com/client/svedka I have the following function which
I have the following PHP script which runs nicely and inserts all the data
I have the following C code from here: http://marknelson.us/1989/10/01/lzw-data-compression/ It states that it uses
Have a look here: In the following code, what would be the type of
I have looked here and from what I understand the following regex simply means
I have the following code here that won't run on ARC since it combines

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.