-
-
Save dlarue/9b5460a23a44d5305356f3a2c6ac8999 to your computer and use it in GitHub Desktop.
Nissan Connect API encryption using Java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package me.netlift.mobile.activities; | |
import android.util.Base64; | |
import java.security.Key; | |
import javax.crypto.Cipher; | |
import javax.crypto.spec.SecretKeySpec; | |
public class NissanConnectEncryption { | |
public static String doEncrypt(String paramString) | |
{ | |
String basePRM = "uyI5Dj9g8VCOFDnBRUbr3g"; | |
return cipherEncrypt(paramString.getBytes(), basePRM); | |
} | |
private static String cipherEncrypt(byte[] paramArrayOfByte, String paramString) | |
{ | |
try | |
{ | |
Key key = new SecretKeySpec(paramString.getBytes(), "Blowfish"); | |
Cipher localCipher = Cipher.getInstance("Blowfish/ECB/PKCS5Padding"); | |
localCipher.init(1, key); | |
paramArrayOfByte = localCipher.doFinal(paramArrayOfByte); | |
return Base64.encodeToString(paramArrayOfByte, 0); | |
} | |
catch (Exception ex) | |
{ | |
ex.printStackTrace(); | |
} | |
return null; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment