mirkosertic / Bytecoder

Framework to interpret and transpile JVM bytecode to JavaScript, OpenCL or WebAssembly.

Home Page:https://www.mirkosertic.de/blog/2017/06/compiling-bytecode-to-javascript/

Repository from Github https://github.commirkosertic/BytecoderRepository from Github https://github.commirkosertic/Bytecoder

Digest Value not match

marcom1981 opened this issue · comments

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=