0

I am working on mobile product. We are using the data in xml document. In order to keep our data secure we need an encryption algorithm(but we don't want the existing algorithm to import)

Can u give me some steps to encrypt the data.(if code example is most welcome).

4
  • 1
    stackoverflow.com/questions/17079579/aes-algo-decryption-issue/… . here's a implementation for encryption and decryption. Here's the android developer blog for the same android-developers.blogspot.in/2013/02/… Commented Jul 23, 2013 at 9:17
  • if you got the answer, try to accept that. Commented Jul 23, 2013 at 9:57
  • 1
    It is always best to use ready made encryption algorithm, than to make your own. The main reason is - encryption turns meaningful things into garbage by definition. And it is very difficult to evaluate it. Only dedicated expert, working for quite a long time, can tell if your scheme produces good enough garbage. So even if you do produce your own algorithm, you wouldn't have any guarantees unless you publish it for a review. Commented Jul 23, 2013 at 12:59
  • Please see this: blogs.msdn.com/b/ericlippert/archive/2011/09/27/… Commented Jul 23, 2013 at 14:37

3 Answers 3

2

To be more secure, you have to do with your own secret key. Try to use this code

   KeyStore ks = KeyStore.getInstance();
 // get the names of all keys created by our app
 String[] keyNames = ks.saw("");

 // store a symmetric key in the keystore
 SecretKey key = Crypto.generateKey();
 boolean success = ks.put("secretKey1", key.getEncoded());
 // check if operation succeeded and get error code if not
 if (!success) {
    int errorCode = ks.getLastError();
    throw new RuntimeException("Keystore error: " + errorCode); 
 }

 // get a key from the keystore
 byte[] keyBytes = ks.get("secretKey1");
 SecretKey key = new SecretKeySpec(keyBytes, "AES");

 // delete a key
 boolean success = ks.delete("secretKey1");
Sign up to request clarification or add additional context in comments.

Comments

1

If you want to develop your own encryption scheme, be prepared to embark on a research project. You can use any of standard encryption algorithms like AES/DES etc, with your private keys that are sufficiently long and difficult to crack.

Comments

0
public string PassEncrypt(string Password)
{
    // Encrypting the password entered by User
    // ======================================================
    MD5 md5 = new MD5CryptoServiceProvider();
    md5.ComputeHash(ASCIIEncoding.ASCII.GetBytes(Password));
    byte[] result = md5.Hash;
    StringBuilder strBuilder = new StringBuilder();
    for (int i = 0; i < result.Length; i++)
    {
        strBuilder.Append(result[i].ToString("x2"));
    }
    return strBuilder.ToString();
    // ======================================================
}

OR

You may refer on this links :

developer.motorala.com

codereview.stackexchange.com

android snippets

java-tips.org

1 Comment

That's hashing, not encryption.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.