james raygan
james raygan

Reputation: 701

Encryption & Decryption algorithm

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).

Upvotes: 0

Views: 1694

Answers (3)

Murali Mohan
Murali Mohan

Reputation: 759

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.

Upvotes: 1

RAAAAM
RAAAAM

Reputation: 3380

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");

Upvotes: 2

ggcodes
ggcodes

Reputation: 2899

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

Upvotes: 0

Related Questions