List of usage examples for org.bouncycastle.crypto.digests WhirlpoolDigest WhirlpoolDigest
public WhirlpoolDigest()
From source file:cologne.eck.peafactory.gui.Menu.java
License:Open Source License
@Override public void actionPerformed(ActionEvent ape) { //JComponent source = (JComponent) ape.getSource(); String command = ape.getActionCommand(); //Menu/*www . j a v a 2 s . com*/ if (command.equals("newProject")) { ProjectSelection proj = new ProjectSelection(); Point p = MainView.getFrameLocation(); proj.setLocation((int) p.getX() + 100, (int) p.getY() + 60); proj.setVisible(true); } else if (command.equals("randomPassword")) { PasswordGeneratorDialog pg = new PasswordGeneratorDialog(PeaFactory.getFrame()); pg.setVisible(true); } else if (command.equals("keyboard")) { int input = JOptionPane.showConfirmDialog(PeaFactory.getFrame(), languageBundle.getString("add_keyboard"), " ", JOptionPane.YES_NO_OPTION); if (input == 0) { FileModifier.setSetKeyboard(true); } else { FileModifier.setSetKeyboard(false); } } else if (command.equals("psw_generator")) { int input = JOptionPane.showConfirmDialog(PeaFactory.getFrame(), languageBundle.getString("add_psw_generator"), " ", JOptionPane.YES_NO_OPTION); if (input == 0) { FileModifier.setPswGenerator(true); } else { FileModifier.setPswGenerator(false); } } else if (command.equals("quit")) { System.exit(0); } else if (command.equals("generalPeaSettings")) { @SuppressWarnings("unused") GeneralPeaSettings imageSetting = new GeneralPeaSettings(); } else if (command.equals("setThoughtless")) { securityLevel = 1; setSecurityLevel(1); } else if (command.equals("setLow")) { securityLevel = 2; setSecurityLevel(2); } else if (command.equals("setStandard")) { securityLevel = 3; setSecurityLevel(3); } else if (command.equals("setHigh")) { securityLevel = 4; setSecurityLevel(4); } else if (command.equals("setParanoid")) { securityLevel = 5; setSecurityLevel(5); } else if (command.equals("setBcrypt")) { setSecurityLevel(securityLevel); KeyDerivation.setKdf(new BcryptKDF()); } else if (command.equals("setScrypt")) { setSecurityLevel(securityLevel); KeyDerivation.setKdf(new ScryptKDF()); } else if (command.equals("setDragonfly")) { setSecurityLevel(securityLevel); CatenaKDF.setVersionID("Dragonfly-Full"); KeyDerivation.setKdf(new CatenaKDF()); } else if (command.equals("setButterfly")) { setSecurityLevel(securityLevel); CatenaKDF.setVersionID("Butterfly-Full"); KeyDerivation.setKdf(new CatenaKDF()); } else if (command.equals("setPomelo")) { setSecurityLevel(securityLevel); KeyDerivation.setKdf(new PomeloKDF()); } else if (command.equals("setBcryptParameters")) { @SuppressWarnings("unused") BcryptSetting bcryptSetting = new BcryptSetting(); } else if (command.equals("setPomeloParameters")) { @SuppressWarnings("unused") PomeloSetting pomeloSetting = new PomeloSetting(); } else if (command.equals("setScryptParameters")) { @SuppressWarnings("unused") ScryptSetting scryptSetting = new ScryptSetting(); } else if (command.equals("setCatenaParameters")) { @SuppressWarnings("unused") CatenaSetting catenaSetting = new CatenaSetting(); } else if (command.equals("setImageParameters")) { @SuppressWarnings("unused") ImageSetting imageSetting = new ImageSetting(); } else if (command.equals("setShacal2")) { CipherStuff.setCipherAlgo(new Shacal2Engine()); } else if (command.equals("setThreefish256")) { CipherStuff.setCipherAlgo(new ThreefishEngine(256)); } else if (command.equals("setThreefish512")) { CipherStuff.setCipherAlgo(new ThreefishEngine(512)); } else if (command.equals("setThreefish1024")) { CipherStuff.setCipherAlgo(new ThreefishEngine(1024)); } else if (command.equals("setTwofish")) { CipherStuff.setCipherAlgo(new TwofishEngine()); } else if (command.equals("setSerpent")) { CipherStuff.setCipherAlgo(new SerpentEngine()); } else if (command.equals("setAES")) { CipherStuff.setCipherAlgo(new AESEngine()); } else if (command.equals("setAESFast")) { CipherStuff.setCipherAlgo(new AESFastEngine()); // hash function: } else if (command.equals("setWhirlpool")) { HashStuff.setHashAlgo(new WhirlpoolDigest()); } else if (command.equals("setKeccak")) { HashStuff.setHashAlgo(new SHA3Digest()); } else if (command.equals("setSha512")) { HashStuff.setHashAlgo(new SHA512Digest()); } else if (command.equals("setSha384")) { HashStuff.setHashAlgo(new SHA384Digest()); } else if (command.equals("setSkein512")) { HashStuff.setHashAlgo(new SkeinDigest(512, 512)); } else if (command.equals("setBlake512")) { HashStuff.setHashAlgo(new Blake2bDigest()); // } else if (command.equals("setRipemd256")) { // HashStuff.setHashAlgo( new RIPEMD256Digest() ); } else if (command.equals("setRipemd320")) { HashStuff.setHashAlgo(new RIPEMD320Digest()); } else if (command.equals("setDE")) { PeaFactory.setI18n("de"); } else if (command.equals("setEN")) { PeaFactory.setI18n("en"); } else if (command.equals("notes")) { @SuppressWarnings("unused") InfoDialog info = new InfoDialog(languageBundle.getString("notes_description"), null, "notes"); } else if (command.equals("editor")) { @SuppressWarnings("unused") InfoDialog info = new InfoDialog(languageBundle.getString("editor_description"), null, "editor"); } else if (command.equals("image")) { @SuppressWarnings("unused") InfoDialog info = new InfoDialog(languageBundle.getString("image_description"), null, "image"); } else if (command.equals("keyboard_info")) { @SuppressWarnings("unused") InfoDialog info = new InfoDialog("Onscreen Keyboard", null, "keyboard"); } else if (command.equals("file")) { @SuppressWarnings("unused") InfoDialog info = new InfoDialog(languageBundle.getString("file_description"), null, "file"); } else if (command.equals("problemHelp")) { JOptionPane pane = new JOptionPane(languageBundle.getString("problem_help_dialog"), JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_OPTION, null, null);//new ImageIcon(PswDialogView.getImage()), null); pane.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 12)); //pane.setIconImage(PswDialogView.getImage()); pane.setVisible(true); //pane.showMessageDialog(null, languageBundle.getString("problem_help_dialog"), null, JOptionPane.PLAIN_MESSAGE); } else if (command.equals("howToUse")) { JOptionPane.showMessageDialog(PeaFactory.getFrame(), languageBundle.getString("how_to_use_dialog"), null, JOptionPane.PLAIN_MESSAGE); } else if (command.equals("aboutLicense")) { JOptionPane.showMessageDialog(PeaFactory.getFrame(), languageBundle.getString("about_license_dialog"), null, JOptionPane.PLAIN_MESSAGE); } }
From source file:com.gpfcomics.android.cryptnos.CryptnosApplication.java
License:Open Source License
@Override public void onCreate() { // Do whatever the super needs to do: super.onCreate(); // Open the database using the DB adaptor so we can access the // database://from w w w. j a v a2s. c om DBHelper = new ParamsDbAdapter(this); DBHelper.open(); // Set the root for all import/export activites. For now, we'll // hard code this to the root directory of the external storage // device, usually an SD card. We may change this in the future. importExportRoot = Environment.getExternalStorageDirectory(); // Get the shared preferences: prefs = getSharedPreferences("CryptnosPrefs", Context.MODE_PRIVATE); // Set the text encoding. Ideally, we will get this from the shared // preferences, but if it doesn't exist, try to get the default value. // We'll try to get the system "file.encoding" value if we can, but // fall back on UTF-8 as a last resort. The try/catch is because // System.getProperty() can technically crash on us, but it's probably // not very likely. Note that whatever we get from wherever we get // it, we'll write it back to the preferences; this is so the // preference gets written at least on the first instance. try { textEncoding = prefs.getString(PREFS_TEXT_ENCODING, System.getProperty("file.encoding", TEXT_ENCODING_UTF8)); } catch (Exception e) { textEncoding = prefs.getString(PREFS_TEXT_ENCODING, TEXT_ENCODING_UTF8); } SharedPreferences.Editor editor = prefs.edit(); editor.putString(PREFS_TEXT_ENCODING, textEncoding); editor.commit(); // Generate the parameter salt: refreshParameterSalt(); // Get our boolean preferences: copy to clipboard, show master passwords, and // clear passwords on focus loss. copyPasswordsToClipboard = prefs.getBoolean(PREFS_COPY_TO_CLIPBOARD, true); showMasterPassword = prefs.getBoolean(PREFS_SHOW_MASTER_PASSWD, false); clearPasswordsOnFocusLoss = prefs.getBoolean(PREFS_CLEAR_PASSWDS_ON_FOCUS_LOSS, false); // Now build our hash table of hash algorithms to lengths: try { // Get the list of hashes from the string resources: String[] hashes = getResources().getStringArray(R.array.hashList); // Declare our hash table and initialize its size to the same size // as the string array of hash names: hashLengths = new Hashtable<String, Integer>(hashes.length); // We're using two different hashing engines, the internal one and the // Bouncy Castle one, so we'll need a reference to both: MessageDigest internalHasher = null; Digest bcHasher = null; // Declare integers to hold the raw byte length and the Base64-encoded // length of each digest: int byteLength = 0; int b64Length = 0; // Loop through the hash name list: for (int i = 0; i < hashes.length; i++) { // If we're using an internal hasher, get the a copy of the // engine and find out its byte length: if (hashes[i].compareTo("MD5") == 0 || hashes[i].compareTo("SHA-1") == 0 || hashes[i].compareTo("SHA-256") == 0 || hashes[i].compareTo("SHA-384") == 0 || hashes[i].compareTo("SHA-512") == 0) { internalHasher = MessageDigest.getInstance(hashes[i]); byteLength = internalHasher.getDigestLength(); } // For the Bouncy Castle engines, we'll need to declare each // individual object and then get its byte length: else if (hashes[i].compareTo("RIPEMD-160") == 0) { bcHasher = new RIPEMD160Digest(); byteLength = bcHasher.getDigestSize(); } else if (hashes[i].compareTo("Tiger") == 0) { bcHasher = new TigerDigest(); byteLength = bcHasher.getDigestSize(); } else if (hashes[i].compareTo("Whirlpool") == 0) { bcHasher = new WhirlpoolDigest(); byteLength = bcHasher.getDigestSize(); } // Now calculate the Base64-encoded length. This formula comes // from the Base64 Wikipedia article: // https://secure.wikimedia.org/wikipedia/en/wiki/Base64 b64Length = (byteLength + 2 - ((byteLength + 2) % 3)) / 3 * 4; // Now store the hash name and length into the hash table: hashLengths.put(hashes[i], Integer.valueOf(b64Length)); } // If anything blows up, set the hash table to null, which we'll catch // as an error later: } catch (Exception e1) { hashLengths = null; } }
From source file:com.gpfcomics.android.cryptnos.SiteParameters.java
License:Open Source License
/** * Given the user's secret passphrase, combine it with all the other * site parameters saved within to produce the generated password and * return it to the theApp.//from www. j a v a 2s .c o m * @param secret The user's secret passphrase, which is never stored. * @param handler If not null, this handler will be notified of the * progress of the generation process, for the purpose of updating a * progress dialog, for example. * @return A pseudo-random password generated from the site parameters. * @throws Exception Thrown when any error occurs. */ public String generatePassword(String secret, Handler handler) throws Exception { Message msg = null; Bundle b = null; ; // Asbestos underpants: try { // The character limit must be zero or greater, while the // iteration count must be one or greater: if (charLimit >= 0 && iterations > 0) { // Concatenate the site and passphrase values, then // convert the string to a byte array for hashing: byte[] result = site.concat(secret).getBytes(theApp.getTextEncoding()); // We will use one of two hashing engines. Internally, // Java supports MD5, SHA-1, and a trio of SHA-2 methods. // We'll assume that since these are built-in, they must // be optimized compared to external definitions. If // the selected hash is one of these, we'll use the // internal engine. MessageDigest internalHasher = null; Digest bcHasher = null; if (hash.compareTo("MD5") == 0 || hash.compareTo("SHA-1") == 0 || hash.compareTo("SHA-256") == 0 || hash.compareTo("SHA-384") == 0 || hash.compareTo("SHA-512") == 0) { internalHasher = MessageDigest.getInstance(hash); } // If it is any other engine, we'll fall back to the // Bouncy Castle implementations. We may add more later, // but for now we'll only use the same ones supported by // the .NET version of Cryptnos. There, we actually // re-implemented their code to fit with the .NET hashing // class structure; here, we'll using Bouncy Castle out // of the box, so it's trivial to implement them all. else if (hash.compareTo("RIPEMD-160") == 0) { bcHasher = new RIPEMD160Digest(); } else if (hash.compareTo("Tiger") == 0) { bcHasher = new TigerDigest(); } else if (hash.compareTo("Whirlpool") == 0) { bcHasher = new WhirlpoolDigest(); } // If we're using the internal hashing engine, we've // got things easy. The most complex part is feeding the // hash back into the engine for multiple iterations. if (internalHasher != null) { for (int i = 0; i < iterations; i++) { result = internalHasher.digest(result); if (handler != null) { msg = handler.obtainMessage(); b = new Bundle(); b.putInt("iteration", i); b.putString("password", null); msg.setData(b); handler.sendMessage(msg); } } } // If we're using the Bouncy Castle stuff, we'll need to // do a bit more work. Declare the result, feed it to // the engine, and get back the hash. Note that we redeclare // the result byte array after the update so each iteration // puts the result hash into the array. Also note that we // make sure to reset the engine after each iteration, which // apparently the built-in engines do automagically. else if (bcHasher != null) { for (int i = 0; i < iterations; i++) { bcHasher.update(result, 0, result.length); result = new byte[bcHasher.getDigestSize()]; bcHasher.doFinal(result, 0); bcHasher.reset(); if (handler != null) { msg = handler.obtainMessage(); b = new Bundle(); b.putInt("iteration", i); b.putString("password", null); msg.setData(b); handler.sendMessage(msg); } } } // By now, we *should* have the intermediate hash in hand. // We'll double check with a null check here, just in case. if (result != null) { // Get the raw hash as a Base64 string: String b64hash = base64String(result); // Now that we've got the hash string, we need to apply // our modifications. First, the character type // restriction. Based on the user's choice in the // drop-down, run the hash through some regular // expressions to chop out unwanted characters: Pattern p = null; switch (charTypes) { // Alphanumerics, change others to underscores case 1: p = Pattern.compile("\\W"); b64hash = p.matcher(b64hash).replaceAll("_"); break; // Alphanumerics only case 2: p = Pattern.compile("[^a-zA-Z0-9]"); b64hash = p.matcher(b64hash).replaceAll(""); break; // Alphabetic characters only case 3: p = Pattern.compile("[^a-zA-Z]"); b64hash = p.matcher(b64hash).replaceAll(""); break; // Numbers only case 4: p = Pattern.compile("\\D"); b64hash = p.matcher(b64hash).replaceAll(""); break; // By default, use all generated characters default: break; } // Next, apply the character limit. If it's any- // thing greater than zero, get only the first so // many characters: if (charLimit > 0 && b64hash.length() > charLimit) b64hash = b64hash.substring(0, charLimit); // Now we have our final value. Display it back // to the user and get ready to save it to the // database. if (handler != null) { msg = handler.obtainMessage(); b = new Bundle(); b.putInt("iteration", -100); b.putString("password", b64hash); msg.setData(b); handler.sendMessage(msg); } return b64hash; } // If for some reason something failed, the result could // be null. Warn the user as such: else { throw new Exception(theApp.getResources().getString(R.string.error_null_hash)); } } // If the iterations or character limit parsing didn't // come up roses, show error messages. Note that there's // also a generic "unknown" one here, just in case, but // it's probably irrelevant. else { if (iterations <= 0) throw new Exception(theApp.getResources().getString(R.string.error_bad_iterations)); else if (charLimit < 0) throw new Exception(theApp.getResources().getString(R.string.error_bad_charlimit)); else throw new Exception(theApp.getResources().getString(R.string.error_unknown)); } } // This should probably be more robust, but for now just throw back // out any exception we caught: catch (Exception e) { throw e; } }
From source file:edu.vt.middleware.crypt.digest.Whirlpool.java
License:Open Source License
/** Creates an uninitialized instance of an Whirlpool digest. */ public Whirlpool() { super(new WhirlpoolDigest()); }
From source file:edu.vt.middleware.crypt.digest.Whirlpool.java
License:Open Source License
/** * Creates a new Whirlpool digest that may optionally be initialized with * random data./*from ww w .ja va2 s . c o m*/ * * @param randomize True to randomize initial state of digest, false * otherwise. */ public Whirlpool(final boolean randomize) { super(new WhirlpoolDigest()); if (randomize) { setRandomProvider(new SecureRandom()); setSalt(getRandomSalt()); } }
From source file:edu.vt.middleware.crypt.digest.Whirlpool.java
License:Open Source License
/** * Creates a new Whirlpool digest and initializes it with the given salt. * * @param salt Salt data used to initialize digest computation. */// w ww . j av a 2 s . c o m public Whirlpool(final byte[] salt) { super(new WhirlpoolDigest()); setSalt(salt); }
From source file:org.cryptacular.spec.DigestSpec.java
License:Open Source License
/** * Creates a new digest instance./*from w w w.ja v a2s .co m*/ * * @return Digest instance. */ @Override public Digest newInstance() { final Digest digest; if ("GOST3411".equalsIgnoreCase(algorithm)) { digest = new GOST3411Digest(); } else if ("MD2".equalsIgnoreCase(algorithm)) { digest = new MD2Digest(); } else if ("MD4".equalsIgnoreCase(algorithm)) { digest = new MD4Digest(); } else if ("MD5".equalsIgnoreCase(algorithm)) { digest = new MD5Digest(); } else if ("RIPEMD128".equalsIgnoreCase(algorithm) || "RIPEMD-128".equalsIgnoreCase(algorithm)) { digest = new RIPEMD128Digest(); } else if ("RIPEMD160".equalsIgnoreCase(algorithm) || "RIPEMD-160".equalsIgnoreCase(algorithm)) { digest = new RIPEMD160Digest(); } else if ("RIPEMD256".equalsIgnoreCase(algorithm) || "RIPEMD-256".equalsIgnoreCase(algorithm)) { digest = new RIPEMD256Digest(); } else if ("RIPEMD320".equalsIgnoreCase(algorithm) || "RIPEMD-320".equalsIgnoreCase(algorithm)) { digest = new RIPEMD320Digest(); } else if ("SHA1".equalsIgnoreCase(algorithm) || "SHA-1".equalsIgnoreCase(algorithm)) { digest = new SHA1Digest(); } else if ("SHA224".equalsIgnoreCase(algorithm) || "SHA-224".equalsIgnoreCase(algorithm)) { digest = new SHA224Digest(); } else if ("SHA256".equalsIgnoreCase(algorithm) || "SHA-256".equalsIgnoreCase(algorithm)) { digest = new SHA256Digest(); } else if ("SHA384".equalsIgnoreCase(algorithm) || "SHA-384".equalsIgnoreCase(algorithm)) { digest = new SHA384Digest(); } else if ("SHA512".equalsIgnoreCase(algorithm) || "SHA-512".equalsIgnoreCase(algorithm)) { digest = new SHA512Digest(); } else if ("SHA3".equalsIgnoreCase(algorithm) || "SHA-3".equalsIgnoreCase(algorithm)) { digest = new SHA3Digest(size); } else if ("Tiger".equalsIgnoreCase(algorithm)) { digest = new TigerDigest(); } else if ("Whirlpool".equalsIgnoreCase(algorithm)) { digest = new WhirlpoolDigest(); } else { throw new IllegalStateException("Unsupported digest algorithm " + algorithm); } return digest; }
From source file:org.jcryptool.visual.hashing.views.HashingView.java
License:Open Source License
private String computeHash(String hashName, String inputText, Text hashText) { hash = hash.getName(hashName);//from ww w . j a v a 2 s . com byte[] digest = null; switch (hash) { case MD2: MD2Digest md2 = new MD2Digest(); md2.update(inputText.getBytes(), 0, inputText.getBytes().length); digest = new byte[md2.getDigestSize()]; md2.doFinal(digest, 0); break; case MD4: MD4Digest md4 = new MD4Digest(); md4.update(inputText.getBytes(), 0, inputText.getBytes().length); digest = new byte[md4.getDigestSize()]; md4.doFinal(digest, 0); break; case MD5: MD5Digest md5 = new MD5Digest(); md5.update(inputText.getBytes(), 0, inputText.getBytes().length); digest = new byte[md5.getDigestSize()]; md5.doFinal(digest, 0); break; case SHA1: SHA1Digest sha1 = new SHA1Digest(); sha1.update(inputText.getBytes(), 0, inputText.getBytes().length); digest = new byte[sha1.getDigestSize()]; sha1.doFinal(digest, 0); break; case SHA256: SHA256Digest sha256 = new SHA256Digest(); sha256.update(inputText.getBytes(), 0, inputText.getBytes().length); digest = new byte[sha256.getDigestSize()]; sha256.doFinal(digest, 0); break; case SHA512: SHA512Digest sha512 = new SHA512Digest(); sha512.update(inputText.getBytes(), 0, inputText.getBytes().length); digest = new byte[sha512.getDigestSize()]; sha512.doFinal(digest, 0); break; case SHA3_224: SHA3.Digest224 sha3_224 = new SHA3.Digest224(); sha3_224.update(inputText.getBytes(), 0, inputText.getBytes().length); digest = new byte[sha3_224.getDigestLength()]; digest = sha3_224.digest(); break; case SHA3_256: SHA3.Digest256 sha3_256 = new SHA3.Digest256(); sha3_256.update(inputText.getBytes(), 0, inputText.getBytes().length); digest = new byte[sha3_256.getDigestLength()]; digest = sha3_256.digest(); break; case SHA3_384: SHA3.Digest384 sha3_384 = new SHA3.Digest384(); sha3_384.update(inputText.getBytes(), 0, inputText.getBytes().length); digest = new byte[sha3_384.getDigestLength()]; digest = sha3_384.digest(); break; case SHA3_512: SHA3.Digest512 sha3_512 = new SHA3.Digest512(); sha3_512.update(inputText.getBytes(), 0, inputText.getBytes().length); digest = new byte[sha3_512.getDigestLength()]; digest = sha3_512.digest(); break; case SKEIN_256: Skein.Digest_256_256 skein_256 = new Skein.Digest_256_256(); skein_256.update(inputText.getBytes(), 0, inputText.getBytes().length); digest = new byte[skein_256.getDigestLength()]; digest = skein_256.digest(); break; case SKEIN_512: Skein.Digest_512_512 skein_512 = new Skein.Digest_512_512(); skein_512.update(inputText.getBytes(), 0, inputText.getBytes().length); digest = new byte[skein_512.getDigestLength()]; digest = skein_512.digest(); break; case SKEIN_1024: Skein.Digest_1024_1024 skein_1024 = new Skein.Digest_1024_1024(); skein_1024.update(inputText.getBytes(), 0, inputText.getBytes().length); digest = new byte[skein_1024.getDigestLength()]; digest = skein_1024.digest(); break; case RIPEMD160: RIPEMD160Digest ripemd160 = new RIPEMD160Digest(); ripemd160.update(inputText.getBytes(), 0, inputText.getBytes().length); digest = new byte[ripemd160.getDigestSize()]; ripemd160.doFinal(digest, 0); break; case SM3: SM3Digest sm3 = new SM3Digest(); sm3.update(inputText.getBytes(), 0, inputText.getBytes().length); digest = new byte[sm3.getDigestSize()]; sm3.doFinal(digest, 0); break; case TIGER: TigerDigest tiger = new TigerDigest(); tiger.update(inputText.getBytes(), 0, inputText.getBytes().length); digest = new byte[tiger.getDigestSize()]; tiger.doFinal(digest, 0); break; case GOST3411: GOST3411Digest gost3411 = new GOST3411Digest(); gost3411.update(inputText.getBytes(), 0, inputText.getBytes().length); digest = new byte[gost3411.getDigestSize()]; gost3411.doFinal(digest, 0); break; case WHIRLPOOL: WhirlpoolDigest whirlpool = new WhirlpoolDigest(); whirlpool.update(inputText.getBytes(), 0, inputText.getBytes().length); digest = new byte[whirlpool.getDigestSize()]; whirlpool.doFinal(digest, 0); break; default: break; } String hashHexValue = new String(Hex.encode(digest)); if (btnHexadezimal.getSelection()) { String hashValueOutput = hashHexValue.toUpperCase().replaceAll(".{2}", "$0 "); //$NON-NLS-1$ //$NON-NLS-2$ hashText.setText(hashValueOutput); } else if (btnDezimal.getSelection()) { String hashValue = hexToDecimal(hashHexValue); hashValue = hashValue.replaceAll(".{3}", "$0 "); //$NON-NLS-1$ //$NON-NLS-2$ hashText.setText(hashValue); } else if (btnBinary.getSelection()) { String hashValue = hexToBinary(hashHexValue); hashValue = hashValue.replaceAll(".{8}", "$0#"); //$NON-NLS-1$ //$NON-NLS-2$ hashText.setText(hashValue); } return hashHexValue; }