public EncryptionKeys( @Nullable byte[] adminKey, @Nullable byte[] memberKey, @Nullable byte[] guestKey) { _adminKeyBytes = adminKey; _memberKeyBytes = memberKey; _guestKeyBytes = guestKey; _adminKey = null; _memberKey = null; _guestKey = null; if (_adminKeyBytes != null) { _adminKey = BleUtils.bytesToHexString(_adminKeyBytes); } if (_memberKeyBytes != null) { _memberKey = BleUtils.bytesToHexString(_memberKeyBytes); } if (_guestKeyBytes != null) { _guestKey = BleUtils.bytesToHexString(_guestKeyBytes); } }
private String getKeyFromString(String key) { if (key == null) { return null; } String retKey = null; if (key.length() == BleBaseEncryption.AES_BLOCK_SIZE * 2) { retKey = key; } if (key.length() == BleBaseEncryption.AES_BLOCK_SIZE) { byte[] keyBytes = key.getBytes(Charset.forName("UTF-8")); retKey = BleUtils.bytesToHexString(keyBytes); } return retKey; }