/    Sign up×
Community /Pin to ProfileBookmark

Unicode conversion UTF16LE ?

Hi,

I’m trying to get the same results in javascript as in php.

The Original php encode is
base64_encode(hash(‘sha256’,iconv(“ISO-8859-1”, “UTF-16LE”,”hello”),true));

This works fine and matches the same result in C++ my friend wrote.

Now putting this into javascript.

The base64 encode works fine.
The sha256 hash works fine.

but when i try to use Base64 encode with the Unicode conversion my results are different to that in php

var code=”hello”;
for (i=0;i<5;i++)
{
current=current+(code.charCodeAt(i))
}
base64_encode(current)

This is the method i’m trying although I feel that it’s just making a string, and coverting that to base64 rather than the unicode,

Any suggestions?

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @hayden spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.23,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...