Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
iPhone和Android的通用加密过程_Android_Encryption - Fatal编程技术网

iPhone和Android的通用加密过程

iPhone和Android的通用加密过程,android,encryption,Android,Encryption,大家好,有没有什么简单的方法可以跨平台对图像进行加密和解密,比如在android中解密在iPhone中加密的图像,反之亦然 提前感谢。您可以使用56位DES加密。iphone和android都支持它。您不能使用RSA,因为映像可能大于127字节。两年前,我尝试使用AES 128位加密。我发现使用AES 128位加密存在局限性,并将其投放市场。所以也要避免AES。java支持AES。因此,nadorid还支持DES您可以使用56位DES加密。iphone和android都支持它。您不能使用RSA,

大家好,有没有什么简单的方法可以跨平台对图像进行加密和解密,比如在android中解密在iPhone中加密的图像,反之亦然


提前感谢。

您可以使用56位DES加密。iphone和android都支持它。您不能使用RSA,因为映像可能大于127字节。两年前,我尝试使用AES 128位加密。我发现使用AES 128位加密存在局限性,并将其投放市场。所以也要避免AES。java支持AES。因此,nadorid还支持DES

您可以使用56位DES加密。iphone和android都支持它。您不能使用RSA,因为映像可能大于127字节。两年前,我尝试使用AES 128位加密。我发现使用AES 128位加密存在局限性,并将其投放市场。所以也要避免AES。java支持AES。因此,nadorid还支持DES

AES加密是在android或IOS中加密文件的最佳方式。在android中,我尝试过加密。此链接将帮助您在中完成。以下代码将帮助您在android中使用密钥加密字节数组

encryptionKey
将是您的密码

 public static byte[] encrypt(byte[] key, byte[] data) throws Exception

        {

            SecretKeySpec skeySpec = new SecretKeySpec(key, "AES");
            Cipher cipher = Cipher.getInstance("AES");
            cipher.init(Cipher.ENCRYPT_MODE, skeySpec);
            byte[] encrypted = cipher.doFinal(data);
            return encrypted;
        }

        /**
         * DEcrypt byte array with given Key using AES Algorithm
         * Key can be generated using <Code>getKey()</Code>
         * @param key  Key that Is used for decrypting data
         * @param data  Data passed to decrypt
         * @return decrypted data
         * */

        public static byte[] decrypt1(byte[] key, byte[] encrypted) throws Exception
        {

            SecretKeySpec skeySpec = new SecretKeySpec(key, "AES");
            Cipher cipher = Cipher.getInstance("AES");
            cipher.init(Cipher.DECRYPT_MODE, skeySpec);
            byte[] decrypted = cipher.doFinal(encrypted);
            return decrypted;
        }
        /**
         * get the Key for encryption this can be used for while decrypting and encrypting too.
         * */
        public static byte[] getKey() throws Exception
        {
            byte[] keyStart = EncrypteDecrypte.encryptionKey.getBytes();
            KeyGenerator kgen = KeyGenerator.getInstance("AES");
            SecureRandom sr = SecureRandom.getInstance("SHA1PRNG");
            sr.setSeed(keyStart);
            kgen.init(128, sr); // 192 and 256 bits may not be available
            SecretKey skey = kgen.generateKey();
            byte[] key = skey.getEncoded();

            return key;
        }

AES加密是在android或IOS中加密文件的最佳方式。在android中,我尝试过加密。此链接将帮助您在中进行加密。以下代码将帮助您在android中使用密钥加密字节数组

encryptionKey
将是您的密码

 public static byte[] encrypt(byte[] key, byte[] data) throws Exception

        {

            SecretKeySpec skeySpec = new SecretKeySpec(key, "AES");
            Cipher cipher = Cipher.getInstance("AES");
            cipher.init(Cipher.ENCRYPT_MODE, skeySpec);
            byte[] encrypted = cipher.doFinal(data);
            return encrypted;
        }

        /**
         * DEcrypt byte array with given Key using AES Algorithm
         * Key can be generated using <Code>getKey()</Code>
         * @param key  Key that Is used for decrypting data
         * @param data  Data passed to decrypt
         * @return decrypted data
         * */

        public static byte[] decrypt1(byte[] key, byte[] encrypted) throws Exception
        {

            SecretKeySpec skeySpec = new SecretKeySpec(key, "AES");
            Cipher cipher = Cipher.getInstance("AES");
            cipher.init(Cipher.DECRYPT_MODE, skeySpec);
            byte[] decrypted = cipher.doFinal(encrypted);
            return decrypted;
        }
        /**
         * get the Key for encryption this can be used for while decrypting and encrypting too.
         * */
        public static byte[] getKey() throws Exception
        {
            byte[] keyStart = EncrypteDecrypte.encryptionKey.getBytes();
            KeyGenerator kgen = KeyGenerator.getInstance("AES");
            SecureRandom sr = SecureRandom.getInstance("SHA1PRNG");
            sr.setSeed(keyStart);
            kgen.init(128, sr); // 192 and 256 bits may not be available
            SecretKey skey = kgen.generateKey();
            byte[] key = skey.getEncoded();

            return key;
        }

请用谷歌搜索android和iphone中的des加密和解密请用谷歌搜索android和iphone中的des加密和解密