hello I tried to send a sms encrypted, but the problem is no
exception, but the SMS does not start
code
public void onClick(View arg0) {
                        sendFeedback(ok);
                        r=DES.crypting("r"+r, TELEPHONY_SERVICE);
                        EnvoiSms envoisms = new EnvoiSms();
                           envoisms.SendMessage(r);
methode for crypto
public class DES{

        protected static String crypting(String textToCrypting, String
keyString ) {
        // Objet de cette classe offre des fonctionnalités pour
        // Chiffrement et le déchiffrement.
        Cipher cipher = null;
        try {
        // Paramètre "DES" spécifie le type de chiffrement que nous voulons
créer
        // Par la méthode de l'usine. Il comprend l'algorithme, le mode et
        // Remplissage. Vous pouvez définir seul algorithme et, dans ce cas
par défaut
        // Valeurs seront utilisées pour la mode et de rembourrage.
        cipher = Cipher.getInstance("DES");
        } catch (NoSuchAlgorithmException ex) {
        // Algorithme cryptographique demandé n'est pas disponible
        ex.printStackTrace();
        } catch (NoSuchPaddingException ex) {
        // Demande un mécanisme de remplissage n'est pas disponible dans
l'environnement.
        ex.printStackTrace();
        }


        // La longueur de keystring est de 8. Il est caractéristique
importante
        // Pour le chiffrement

        byte[] keyData = keyString.getBytes();

        // Objet clé spécifie une clé secrète
        // On utilise pour construire la clé secrète pour notre moteur de
chiffrement à partir d'un octet
        // Tableau
        SecretKeySpec key = new SecretKeySpec(keyData, 0, keyData.length,
"DES");
        try {
        // Initialisation de la mise en place le type d'opération, c'est pour
être
        // Utilisé pour. Dans ce cas - pour le chiffrement.
        cipher.init(Cipher.ENCRYPT_MODE, key);
        } catch (InvalidKeyException ex) {
        // Donnée objet clé est inapproprié pour l'initialisation de ce
chiffre
        ex.printStackTrace();
        }


        int cypheredBytes = 0;


        byte[] inputBytes = textToCrypting.getBytes();
        byte[] outputBytes = new byte[100];
        try {
        // Méthode doFinal crypte les données au tableau outputBytes.
        //Chiffres pour inconnu ou grandes quantités de données mise à jour
méthode plus recommandé
        // Nombre d'octets cryptés sauvegardés dans cypheredBytes variable
        cypheredBytes = cipher.doFinal(inputBytes, 0, inputBytes.length,
outputBytes, 0);
        } catch (IllegalStateException ex) {
        ex.printStackTrace();
        } catch (ShortBufferException ex) {
        ex.printStackTrace();
        } catch (IllegalBlockSizeException ex) {
        ex.printStackTrace();
        } catch (BadPaddingException ex) {
        ex.printStackTrace();
        }


        String str = new String(outputBytes, 0, cypheredBytes);
        inputBytes = str.getBytes();
        return str;
        }
        // Changement d'état de l'objet de chiffrement pour le déchiffrement

        protected static String decrypting(String textCrypting, String
keyString ) {
        //Object of this class provides the functionality for
        //encryption and decryption.
        Cipher cipher = null;
        try {
        //parameter "DES" specifies type of cipher we want to create
        //through the factory method. It includes algorithm, mode and
        //padding. You can define only algorithm and in that case default
        //values will be used for mode and padding.
        cipher = Cipher.getInstance("DES");
        } catch (NoSuchAlgorithmException ex) {
        ex.printStackTrace();
        } catch (NoSuchPaddingException ex) {
        ex.printStackTrace();
        }


        //The lenght of keyString is 8. It's important characteristic
        //for encryption

        byte[] keyData = keyString.getBytes();

        //key object specifies a secret key
        //it uses to construct the secret key for our cipher object from a
byte
        //array
        SecretKeySpec key = new SecretKeySpec(keyData, 0, keyData.length,
"DES");

        try {
        //change state of the cipher object for decrypting
        cipher.init(Cipher.DECRYPT_MODE, key);
        } catch (InvalidKeyException ex) {
        ex.printStackTrace();

        }
        int cypheredBytes = 0;
        byte[] inputBytes = textCrypting.getBytes();
        byte[] outputBytes = new byte[1000];
        try {
        //decrypts data
        cypheredBytes = cipher.doFinal(inputBytes, 0, inputBytes.length,
        outputBytes, 0);
        } catch (IllegalStateException ex) {

        } catch (ShortBufferException ex) {

        } catch (IllegalBlockSizeException ex) {

        } catch (BadPaddingException ex) {

        }

        String str = new String(outputBytes, 0, cypheredBytes);
        return str;
        }

        }

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to