Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Digest Value not match #755

Open
marcom1981 opened this issue Aug 9, 2022 · 0 comments
Open

Digest Value not match #755

marcom1981 opened this issue Aug 9, 2022 · 0 comments

Comments

@marcom1981
Copy link

marcom1981 commented Aug 9, 2022

Hi,
I'm testing to write simple "hello word", for test my crypto suites.
i start from simple hash.

Some static method non are present on bytecoder.
Example MessageDigest.getInstance().

Than i try use BouncyCastle, compile now work but result is not equal at java output:

public class SimpleMain {
    public static void main(String[] args) throws NoSuchAlgorithmException {
        SHA1Digest digest = new SHA1Digest();
        byte[] digestValue = new byte[digest.getDigestSize()];
        byte[] dataTODigest = new byte[4];
        dataTODigest[0]='c';
        dataTODigest[1]='i';
        dataTODigest[2]='a';
        dataTODigest[3]='o';

        String b64Value = new String(Base64.getEncoder().encode(dataTODigest));
        System.out.println("b64Value :"+b64Value);
        digest.update(dataTODigest,0,dataTODigest.length);
        System.out.println("Hash before compute:"+new String(Base64.getEncoder().encode(digestValue),StandardCharsets.UTF_8));
        digest.doFinal(digestValue,0);
        String b64Hash = new String(Base64.getEncoder().encode(digestValue), StandardCharsets.UTF_8);
        System.out.println("Hash :"+b64Hash);

    }
}

this is java output:

b64Value :Y2lhbw==
Hash before compute:AAAAAAAAAAAAAAAAAAAAAAAAAAA=
Hash :Hk6IisZvjdQeAMWnrDajKplQ0nE=

this is wasm end javascript output:

b64Value :Y2lhbw==
bytecoder.js:88 Hash before compute:AAAAAAAAAAAAAAAAAAAAAAAAAAA=
bytecoder.js:88 Hash :K6r70mv+s+MMMKxOx5stObZrVb8=
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant