Android Question PBEWithMD5AndDES, missing Password

trvip

Member
hi,

can you plz help me to convert this piece of java code to B4A?
its throw missing password as error

sKey = "dg4YHEwJv1KLMZrCDE5WtvGq8zumb2YX"

many thx

Java:
Public static String Encrypt(String value) {
        Try {
            byte[] bytes = value != Null ? value.getBytes(UTF8) : new byte[0];
            SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("PBEWithMD5AndDES");
            SecretKey key = keyFactory.generateSecret(new PBEKeySpec(sKey));
            Cipher pbeCipher = Cipher.getInstance("PBEWithMD5AndDES");
            pbeCipher.init(1, key, new PBEParameterSpec(Settings.Secure.getString(this.context.getContentResolver(), "android_id").getBytes(UTF8), 20));
            Return new String(Base64.encode(pbeCipher.doFinal(bytes), 2), UTF8);
        } Catch (Exception e) {
            throw new RuntimeException(e);
        }
}
 
Top