generate SHA1 hash function in Codename One
<p>I need to generate a hash function in CN1. I added the BouncyCastle library, but I don't know how to use it. After searching a lot, I found some examples and came up with this:</p>

<pre><code>@Override
protected void onMain_ButtonSHA1Action(Component c, ActionEvent event) {
    String data = "XXXXXXXXXXXXX";
    SHA1Digest sha1 = new SHA1Digest();
    try {
        byte[] b = data.getBytes("UTF-8");
        sha1.update(b, 0, b.length);
        byte[] hash = new byte[sha1.getDigestSize()];
        sha1.doFinal(hash, 0);

        labelX.setText(hash.toString());

    } catch (Exception ex) {
    }

}
</code></pre>

<p>The result is not working. I know, because I am checking the outcome here: <a href="http://www.sha1-online.com/" rel="nofollow">http://www.sha1-online.com/</a> and it is not the same.</p>