Back to project page SmartPass.
The source code is released under:
Copyright (c) 2013 Dax Earl, Aaron Golliver Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal ...
If you think the Android project SmartPass listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.passwordLib; /*from w ww . j av a2 s . c om*/ import java.io.UnsupportedEncodingException; import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; import javax.crypto.*; import javax.crypto.spec.*; public class SimpleCrypto { private static final String ALGORITHME = "Blowfish"; private static final String TRANSFORMATION = "Blowfish/ECB/PKCS5Padding"; private static final String CHARSET = "ISO-8859-1"; public static String encrypt(String plaintext, String SECRET) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, UnsupportedEncodingException, IllegalBlockSizeException, BadPaddingException { Cipher cipher = Cipher.getInstance(TRANSFORMATION); cipher.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(SECRET.getBytes(CHARSET), ALGORITHME)); return new String(cipher.doFinal(plaintext.getBytes()), CHARSET); } public static String decrypt(String ciphertext, String SECRET) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, UnsupportedEncodingException, IllegalBlockSizeException, BadPaddingException { Cipher cipher = Cipher.getInstance(TRANSFORMATION); cipher.init(Cipher.DECRYPT_MODE, new SecretKeySpec(SECRET.getBytes(), ALGORITHME)); return new String(cipher.doFinal(ciphertext.getBytes(CHARSET)), CHARSET); } }