Why is base64 using CryptoJS different than a standard base64 encode?

php99

To communicate with a server, I need to send the password SHA1 & base64 encoded the same way CryptoJS does this.

My problem is that I'm using VB.NET. The typical base64 encoding (UTF-8) result is different than the results of CryptoJS.

How can I base64 encode the SHA1 string in .NET the same way CryptoJS encodes it?

You can see both results here: https://jsfiddle.net/hn5qqLo7/

var helloworld = "Hello World";
var helloword_sha1 = CryptoJS.SHA1(helloworld);
document.write("SHA1: " + helloword_sha1);

var helloword_base64 = helloword_sha1.toString(CryptoJS.enc.Base64);
document.write("1) Base64: " + helloword_base64);
document.write("2) Base64: " + base64_encode(helloword_sha1.toString()));

where base64_encode converts a given string to a Base 64 encoded string.

I saw a similar question, but I don't understand it. Decode a Base64 String using CryptoJS

Ewoud

In (1) of your fiddle the CryptoJS calculates the SHA1 value of the string, and then, converts the raw bytes to Base64. However (2) first calculates the SHA1 value of 'Hello World' and then puts it in hexadecimal form (consisting of only 0-9 and a-f), and then converts this hexadecimal form of SHA1 to base64. So that is why you end up with two different results.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Why is hex -> base64 so different from base64 -> hex using pack and unpack?

From Dev

Encode base64 and Decode base64 using delphi 2007

From Dev

Encode base64 and Decode base64 using delphi 2007

From Dev

Base64 decode encode, getting different data

From Dev

different results when I encode a character to base64

From Dev

Different output after decode and encode data (base64)

From Dev

Why should you base64 encode the Authorization header?

From Dev

why is the base64 encode java code doing this

From Dev

why is the base64 encode java code doing this

From Dev

Why encode string with base64 if it can be easily decoded

From Dev

encode image to base64, get a invalid base64 string (ios using base64EncodedStringWithOptions)

From Dev

Gmail API send message without using Base64 encode

From Dev

base64 encode HttpPostedFileBase

From Dev

Javascript base64 encode

From Dev

why are python base64 return values different: open(), StringIO()?

From Dev

why are python base64 return values different: open(), StringIO()?

From Java

Mismatch data when using different Base64 libraries

From Dev

Mismatch data when using different Base64 libraries

From Dev

Why decode using base64 not working correctly in C#

From Dev

something better than base64 to encode data that doesn't take up too much processing power

From Dev

Encode Carrierwave attachment to base64 in Rails

From Dev

Base64 encode file and OutOfMemory error

From Dev

How to encode an image resource to base64?

From Dev

Encode a ImageMagick image with Base64

From Java

Base64 Java encode and decode a string

From Dev

Angular 2 encode image to base64

From Dev

Encode a base64 request body into a binary

From Dev

How to (base64) encode a protobuf as a String

From Dev

Encode a FileStream to base64 with c#

Related Related

  1. 1

    Why is hex -> base64 so different from base64 -> hex using pack and unpack?

  2. 2

    Encode base64 and Decode base64 using delphi 2007

  3. 3

    Encode base64 and Decode base64 using delphi 2007

  4. 4

    Base64 decode encode, getting different data

  5. 5

    different results when I encode a character to base64

  6. 6

    Different output after decode and encode data (base64)

  7. 7

    Why should you base64 encode the Authorization header?

  8. 8

    why is the base64 encode java code doing this

  9. 9

    why is the base64 encode java code doing this

  10. 10

    Why encode string with base64 if it can be easily decoded

  11. 11

    encode image to base64, get a invalid base64 string (ios using base64EncodedStringWithOptions)

  12. 12

    Gmail API send message without using Base64 encode

  13. 13

    base64 encode HttpPostedFileBase

  14. 14

    Javascript base64 encode

  15. 15

    why are python base64 return values different: open(), StringIO()?

  16. 16

    why are python base64 return values different: open(), StringIO()?

  17. 17

    Mismatch data when using different Base64 libraries

  18. 18

    Mismatch data when using different Base64 libraries

  19. 19

    Why decode using base64 not working correctly in C#

  20. 20

    something better than base64 to encode data that doesn't take up too much processing power

  21. 21

    Encode Carrierwave attachment to base64 in Rails

  22. 22

    Base64 encode file and OutOfMemory error

  23. 23

    How to encode an image resource to base64?

  24. 24

    Encode a ImageMagick image with Base64

  25. 25

    Base64 Java encode and decode a string

  26. 26

    Angular 2 encode image to base64

  27. 27

    Encode a base64 request body into a binary

  28. 28

    How to (base64) encode a protobuf as a String

  29. 29

    Encode a FileStream to base64 with c#

HotTag

Archive